Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing lines from csv to reduce size for Excel.

Status
Not open for further replies.

Dmanley

Mechanical
Dec 12, 2003
11

How could I delete every second line (or 2 in 3 lines etc..) from a csv file so as to reduce the size so excel could open the full file and analysis the info.?

Thank you for your help.

 
Replies continue below

Recommended for you

I don't quite understand your problem. Is your file more than 65536 records long or does it simply have too much data?

If the data is more than 65536 records long you are SOL you will have to go to a database. Excel will only handle 65536 by 256 number of cells.

If the problem is a data size problem Excel will page the information in and out of memory and also save the undo data (more memory). If you can wait through the swapping time you can load the file and then parse out the data you want. Another solution is again to use a database and import the data into a table and export the required data. A final solution is to use some programming language such as C++ write a program to read the data parse the required data and write another file with the required data.

Whenever you start dealing with a large dataset a database is a better solution than a spreadsheet.
 
The problem is excel probably won't open a file that is too ridiculous in size.

Best bet is to either read the file into Word and save it as parts, then write a VBA macro to decimate each part, then read the decimated parts in (ugly) or else write a very straight forward qbasic program to decimate the entire csv file before even trying to read it into Excel.

Something along the lines of

OPEN "infile.csv" for input as #1
OPEN "Outfile.csv" for output as #2
Repeat
lineinput #1,s$
lineinput #1,s$
writeln #2,s$
until eof
close
end

or whatever the correct syntax is

Cheers

Greg Locock
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor