1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Convert cvs to html

Discussion in 'PHP' started by Fracisc, Oct 3, 2015.

  1. #1
    I have a huge csv file and I want to convert it to html with pagination. I want 10 csv lines per page. Could you help me out with a code please?
     
    Fracisc, Oct 3, 2015 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    "A code" isn't really gonna cut it... you'll need at least 50-100 lines of code to read, parse, output and create a proper pagination system with uri-support. Probably something most people won't be doing for free. It's not that hard, though, and it's a good learning project. Read up on PHP, file-parsing and -reading, and after you've gotten that down, read up on pagination-systems using PHP. You should be able to hack a working example together within a couple of days.
     
    PoPSiCLe, Oct 3, 2015 IP
  3. Vision2Code

    Vision2Code Greenhorn

    Messages:
    33
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    23
    #3
    I thought I saw a program that would convert cvs files to HTML before, not sure if its free (probably not) but maybe you should look into that. Otherwise, you will have to learn how to do it yourself like PoPSiCLe mentioned, or hire someone. I am sure a programmer would do this for a low fee.
     
    Vision2Code, Oct 6, 2015 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #4
    1) I'm assuming you mean CSV (comma separated values), since I don't think you can convert a pharmacy into HTML.

    2) What's the data look like, how do you want it formatted on the output side? Is it actually tabular data so it goes into a table? Is a certain field a header for that row? You're not giving us a lot to work from.

    3) When you say "per page" do you want separate static HTML files, or is this something that would regularly change so you'd want to have it work on the fly? If the former that's not too hard, if the latter you're best off loading the CSV into a database.

    4) I'd probably use PHP for this, as this function:

    http://php.net/manual/en/function.fgetcsv.php

    GREATLY simplifies working with CSV.

    Really we need to see the data, and see how you want each row formatted AND what each row "is" before we can tell you much more.
     
    deathshadow, Oct 6, 2015 IP
    NetStar likes this.
  5. Keteki

    Keteki Active Member

    Messages:
    112
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    90
    #5
    First create a SQL Database & Table, and import the CSV file accordingly. Then you can easily create a html page with pagination via PHP.
     
    Keteki, Oct 9, 2015 IP
  6. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #6
    If all he needs is to read fixed cvs files, why would he need to add another attack vector by adding a database? It's easy to read, parse and even write cvs files with PHP.
     
    PoPSiCLe, Oct 10, 2015 IP
  7. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #7
    It's also grossly inefficient if for example you had a 6000+ records and only want to show ten records starting at number 460.

    If it's a one-off to static HTML, fine, use the file once. If it's something that is going to be built on the fly and have values changed/added/updated, put it into a database so you can leverage things like indexing.

    Hence why that whole "XML database" asshattery is a stunning example of epic /FAIL/
     
    deathshadow, Oct 10, 2015 IP
  8. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #8
    Came here only to say that ;)
     
    NetStar, Oct 11, 2015 IP