Buzzinoffbond / phpliteadmin

Automatically exported from code.google.com/p/phpliteadmin
0 stars 0 forks source link

'Field names in first row' in CSV import drops every 5000 row #246

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. craft big CSV file containing 5000+ rows
2. try importing it

What is the expected output? What do you see instead?
One row per 5000 lines from input file is missing in SQL with successfull SQL 
import status.

This happens because $ields_in_first_row flag is not being cleared after first 
row is skipped.

Simple fix:
                        if($csv_data[0] != NULL || count($csv_data)>1)
                        {
                                $csv_number_of_rows++;
-                               if($fields_in_first_row && 
$csv_number_of_rows==1) continue;
+                               if($fields_in_first_row && 
$csv_number_of_rows==1){
+                                 $fields_in_first_row = FALSE;
+                                continue;
+                               }
                                $csv_col_number = count($csv_data);

Original issue reported on code.google.com by lytbo...@gmail.com on 8 Feb 2014 at 11:42

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r459.

Original comment by crazy4ch...@gmail.com on 9 Feb 2014 at 9:25

GoogleCodeExporter commented 9 years ago
Thanks for reporting this issue.
Just to explain why this happens: Of course it's no integer overflow (php 
automatically casts to float if ints get too big and 5000 is a lot smaller than 
2147483647). The problem is cause because we start a new transaction every 5000 
rows and when we do this, we set $csv_number_of_rows=0.

I just fixed this in svn the same way as you proposed. Thanks.

Original comment by crazy4ch...@gmail.com on 9 Feb 2014 at 9:29