Group records of a CSV file with PHP

0

Good morning, I want to group disordered records within a CSV file using PHP, I thought about using an Arrangement and looking for identical IDs and organize them one below the other, but I could have files of more than 20 thousand records and I do not know what storage capacity the fixes have .

I await your comments.

    
asked by Ricky 29.11.2016 в 16:01
source

1 answer

0

One of the simplest solutions is to load the csv in mysql, using this syntax:

mysql -vvvvv -u -p -h localhost -e "LOAD DATA INFILE" 'INTO TABLE FIELDS TERMINATED BY'; ' (); "

Then you can create a grouping query and rebuild the csv back.

The performance in this method is by far better than doing it directly in php.

Subsequently to generate the csv, you can use:

SELECT DESDE WHERE GROUP BY ORDER BY INTO OUTFILE '' FIELDS TERMINATED BY ', or;' ENCLOSED BY '"' LINES TERMINATED BY '\ n';

I hope you serve

    
answered by 23.09.2017 в 02:11