Skip to main content
18 events
when toggle format what by license comment
Oct 13, 2019 at 17:53 comment added user301446 Hmm yes I see You have same problem with Python script. I think Python is much more powerful but for simple tasks like ad-hoc file or output filtering it's very good. I assume you have some strange input files. So our scripts don't do the splitting as expected.. maybe you should do a hexdump -C on one of the files to check
Oct 13, 2019 at 17:39 comment added jane ward Thanks again EOhm. Tried all 3 scripts as script files. First one returns correct time but 0s in all other fields. Second script returned just the time which is correct. Third script returns time which is correct and 0s for all other fields. Maybe there really is something wrong with my terminal. I'm sure you're right it should work. Strange. Thanks for all your help. And your time. Thank you.
Oct 13, 2019 at 17:09 comment added user301446 The current version definitly work in linux bash (and it has almost nothing to do with bash as the most logic is within awk script). I have linux default gawk installed, I assume You have the same. (I just fixed calculation bug in the 3rd one but over all You should have got the results and no hangs if You tried with last versions.) It's also possible to put all the stuff between the single quotes into an script file (ex. conect.awk) and call it like awk -f concat.awk *.csv > all.csv to be sure it has nothing to do with Your shell environment.
Oct 13, 2019 at 17:01 history edited user301446 CC BY-SA 4.0
edited body
Oct 13, 2019 at 15:51 comment added jane ward Thanks EOhm. I tried everything again with and without headings. Unfortunately it still does not work. I am using Bash on Linux. Maybe that could be the problem. It is obviously working for you so it seems strange it doesn't work for me. Strange. Anyway, I'd like to thank you for all your effort, time, and help. I really appreciate it. Thank you.
Oct 13, 2019 at 15:43 comment added user301446 Because of the other issue @Fedor mentioned.. I had the same thoughts. Eigther some data is lost because not provided in original file (the distance between last line in previous file and the 0 line in next file) - what I assume more, or it is better approach like he did in the python script (do not do the extra increment by 0.05 for time but skip the 0 line in the following files) - which is probably also wrong and causes even more data (the time) to be be inacurate.
Oct 13, 2019 at 15:37 comment added user301446 So now they are all three working correctly, only problem is that the original spaces are lost when You change one field contained in $0. So eigther one should implement some formatting (if it should be human readable with fixed size fonts) or one could set for example $1=$1 before printing out the header to have also the header realigned to be seprated only by OFS instead of original spacing. @janeward
Oct 13, 2019 at 15:34 history edited user301446 CC BY-SA 4.0
Fix Typos in Code and add file headings
Oct 13, 2019 at 15:21 comment added user301446 OK, the loops are fixed (messed up with writing sometimes cnf instead of cfn [currentfieldnumber]). It's fixed.
Oct 13, 2019 at 15:20 history edited user301446 CC BY-SA 4.0
Fix Typos in Code
Oct 13, 2019 at 15:07 comment added user301446 Oh I see something does not work, indeed. I will check.
Oct 13, 2019 at 13:58 comment added jane ward Thanks EOhm. I did delete the all.csv file before running the loops, with and without that rm line. I pasted the awk script into the terminal when it was in the directory of the files. I can see that the variables you're using should work but it doesn't for some reason. Normally I would have the heading kept on the first file and removed from all other files using the awk one-liner: awk '(NR == 1) || (FNR > 1)' *.csv > all.csv Thanks again for your help and your time. Really appreciate it.
Oct 13, 2019 at 13:46 comment added user301446 I incorporated changes (not include the titles). The other part (putting out title for first file) could also be added. But first You need it working.
Oct 13, 2019 at 13:45 history edited user301446 CC BY-SA 4.0
added 15 characters in body
Oct 13, 2019 at 13:43 comment added user301446 @janeward did You execute the rm -f all.csv before starting the awk`? Then it should loop.. You should be able to just copy&paste one of them when You are in the dir the .csv are in (I took that from Your example). Which loop You mean freezes?
Oct 13, 2019 at 12:36 comment added jane ward Thanks EOhm for taking the time to write up the different possibilities. Unfortunately they didn't work. The loops froze up my machine. I'm using the BASH shell if that makes a difference. I've edited in the headings in the sample csv files above as they would appear in the real files in case that makes a difference. I tried with and without headings using your examples. Sadly they still didn't work. I'm probably doing something wrong. I really appreciate you took the time to help a newbie. Thanks.
Oct 13, 2019 at 10:04 history edited user301446 CC BY-SA 4.0
added 1657 characters in body
Oct 12, 2019 at 22:49 history answered user301446 CC BY-SA 4.0