[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

I need some help anons. I have a couple of hundred files in which

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 11
Thread images: 1

File: file.png (41KB, 489x620px) Image search: [Google]
file.png
41KB, 489x620px
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 using
cut -d" " -f4
will 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.
Thread posts: 11
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.