Results 1 to 2 of 2
Hi
So I have a bit of a problem with a CSV data file. It is a record of simulation data where each line is a different trial run.
My ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 03-06-2013 #1Just Joined!
- Join Date
- Mar 2013
- Posts
- 2
add characters to end of line in file (diff num of char per line)
Hi
So I have a bit of a problem with a CSV data file. It is a record of simulation data where each line is a different trial run.
My problem is that each line has a different number of values and MATLAB therefore wont dump the file into a matrix for me. I have been opening the file in spread sheet and adding comma separated zeros to buffer the lines to make them the same length up until now with short simulations.
However I have my final simulation that is really long and exceeds the maximum row length for open office spread sheet (i learned my lesson, next time i will record data in columns).
So i thought i would create a script to add ,0,0,0,0,0,0,0,0 data.
The tricky part is i have to add a different number of zeros (CSV) to each line:
line 1 310 zeros
line 2 253 zeros
line 3 252 zeros
line 4 197 zeros
line 5 145 zeros
line 6 94 zeros
line 7 93 zeros
line 8 46 zeros
line 9 0 zeros
line 10 1 zeros
line 11 2 zeros
I am a bit stumped. I have read about 'adding a character the end of a line' but what i am after is 'adding a character to the end of a specific line'. As in:
append to line 1: ",0" (loop 310 times)
append to line 2: ",0" (loop 253 times)
Any helpful ideas? My linux script syntax is veeery rusty.
cheers
Alex
- 03-06-2013 #2Just Joined!
- Join Date
- Mar 2013
- Posts
- 2
oops, muhahahahaha solved it in MATLAB (made script to count commas then declared zeroed matrix in MATLAB prior to load).
silly me


Reply With Quote
