I need some help anons. I have a couple of hundred files in which I need to extract the final value of column 4 before it nan's (see pic), however each column ends in a different place. I think a while loop would do it but I'm pretty shit at coding and I'm not sure how I'd do it. Any ideas?
>>59429875
get url of each file, this can be done very simply with total commander, learn basics of regular expresions write few lines of code to iterate through files and get values
I'm using C on a linux emulator currently (uni project) but could use perl too.
>>59429875
Try something in shell like:while read -r line; do
val="$(awk '{print $4}' <<< "$line")"
if [[ "$val" == '-nan' ]]; then
break
fi
done < name_of_file
I don't know awk foo well so this can probably be optimized, but this is the general idea. Read each line, extract the column, and test it.
>>59429875
Default C++ file input library does this no problem since everything is a number. You won't have to worry about the spaces/columns ending at different places, and since you use C already you should have little trouble adapting the project to C++.
ALTERNATIVELY: If you have a Matlab license, there is a graphical user interface even through which you can do this. I believe Matlab's free open source counterpart GNU Octave can also do this.
>>59429875
couldnt you simply create a list for each line, and counting the spaces determine where the 4th column is?
>>59430736
this. if you're already using Linux,
try usingcut -d" " -f4will get you the right column.
>>59430858
>matlab
lets not exaggerate here
Thanks for the advice anons, will give it a try!
>>59430736
This works except it gives me the nan when I echo $val, is there a way to echo the value prior to is being nan? As in the value just before the break is triggered.
r u in college ? i think ur missing the point of college
>>59433433
I am, but coding isn't a major component of my degree and so they don't teach it with any great depth. I'm also not bothered about learning it spectacularly well for now, I just want to get my data and move on.