I feel I have a simple problem but can’t seem to learn how to do it right.
I have a csv or txt file with
2.3 4.5 5.6 8
1.2 3.5 7.4 2
…and so on for thousands of line
I want to be able to read line by line and do some math (lets say multiple the third column by -1) and write it all back to an output file. I don’t want to read everything into one array as I’ll be dealing with very large files.
I’ve tried numpy, pandas, csv but one or the other either puts it in scientific notation or adds square brackets or can’t handle that one column is only integers.
Raj Bhangu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
You must parse the file to computer-understandable format, so prefer csv
and use csv module to navigate through the values.