Can anyone please suggest a good csv importing library?

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #1762
    Luzaan23Rocks
    Participant

    Good Day,

    I am looking for a good importing library that will assist in validating the csv data against a database table, manage duplicate entries etc.

    Can anyone suggest a good library?

    Thank you in advance!

    #1763
    alexanderpas
    Guest

    league/csv found at https://csv.thephpleague.com/

    Alternatively, parsecsv/php-parsecsv

    #1764
    Annh1234
    Guest

    LOAD DATA INFILE … INTO TABLE … FIELDS TERMINATED BY . ENCLOSED BY . LINES TERMINATED BY . ;

    then to ignore duplicates, create your table with the unique key, and INSERT IGNORE .. SELECT…

    No need for a library for this… Not unless your text is not really CSV, and it’s corrupt…

    #1765
    pragmageek
    Guest

    i found [https://github.com/box/spout](https://github.com/box/spout) to be hugely performant.

    #1766
    blacm00n
    Guest

    I would suggest league php.
    https://csv.thephpleague.com

    #1768
    psysun
    Guest

    Question because I’ve never heard of a library doing such a thing…
    Is there built in functions or what have you to actually compare a csv file to a database, managing duplicate entries?

    I’ve more or less done the csv parsing and then painstakingly had to do some array comparisons or whatever to compare and find duplicates and the like.

    #1769
    nunchaq
    Guest

    I did wrote one myself. I could find anything that had all things I needed (Column mapping, dates to object etc). It’s honestly simple to write unless you need this ASAP than I would suggest write it yourself.

    Edit – grammar

    #1770
    badasimo
    Guest

    I’m really happy to see all the options that other people are posting, hopefully this is a high google result in the future for people looking to solve this problem. In the past I have used things like phpmyadmin, or written my own. There are some frameworks/software that eat CSVs kind of nice– you can use Drupal migrations to import CSV in a very advanced way, also a software called Quick Base has a pretty decent CSV importer.

    #1771
    [deleted]
    Guest

    The most popular library would be the csv package by league as already mentioned a few times in this thread. That being said it’s easy to build your own using the built-in fopen and fgetcsv functions. I built one that I’ve used on multiple projects that only has 3 methods.

    #1772
    Jascar_Destin
    Guest

    I would suggest Spout

    #1773
    whatshisnuts
    Guest

    I have been using -[https://phpspreadsheet.readthedocs.io/en/latest/](https://phpspreadsheet.readthedocs.io/en/latest/) / [https://github.com/PHPOffice/PhpSpreadsheet](https://github.com/PHPOffice/PhpSpreadsheet)- which is definitely a very large hammer for this use case. But I’ve built some intricate excel reporting files with it and it’s been efficient and very easy to work with.

    #1774
    rias500
    Guest

    https://github.com/spatie/simple-excel is a nice abstraction over box/spout

    #1775
    32gbsd
    Guest

    Its better to code it yourself using raw php. You will end up with a tonne of edge cases that libraries will not support. There was this one instance where I had to switch out the separation car…wait this is not a help forum!

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.