Jump to content

How to get the line number of a CSV file?


lopes_andre

Recommended Posts

There is no real good way of doing it. You'll need to open the file, read the entire thing into an array, count the size of the array, then loop back through 9the array) until you get to the line you want.

 

You'll probably have no use for fgetcsv by then.

Link to comment
Share on other sites

Hi,

 

Thanks for the reply.

 

It is a good idea to store in one array 200MB of data or should be better to get the lines of the CSV one by one?

 

The deal is that I have a 200MB CSV file that I need to write the INSERT's INTO to put in the database, but I don't know if it is a good idea to store the data in one array or construct the INSERTS one by one in a loop.

 

Best Regards,

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.