Alex Rivera | Logout

Remove Commas from Large CSV (1GB)

Asked 2012-07-31T15:53:14.370
8

I have a large CSV file (1GB) that I would like to remove commas from. The data are all positive integers. Methods I have tried include dlmwrite with a space as the delimiter, but the output is then output in decimal format. I have also tried to use the fprintf command, but then I lose the shape of the matrix (i.e. all data appear in one line or column).

Thus,

Is there a simple way to read in from a CSV (input.txt):

1, 2, 3, 4, 5
2, 3, 4, 5, 6

and then output to a text file (output.txt) in the form:

1 2 3 4 5
2 3 4 5 6
Edit
Report

1 Answer

1

Personally, I like to use sed, a command line program that replaces strings.

This application is available on linux and via a cygwin install also in windows.

Using

sed -i 's/,/ /g' filename

all the commas in the file are replaced by spaces.

answered 2012-08-06T14:09:14.317

Your Answer