Tag Info

Hot answers tagged

5

I think you need a heavier programming language for this. Python is my language of choice so here's a simple script with a simple example of a test: import sys tests = [ lambda a, b, c, d, e: a+1==b and b+1==c and c+1==d and d+1==e, ] with open(sys.argv[1]) as f: for line in f: if any(t(*map(int, line.split(','))) for t in tests): ...


4

If we interpret your requirement to mean that the value of the third field (column) should be one more than that of the second field (column), then with awk you can do things like awk -F, ' $3==$2+1 {print "row "NR": "$0" was removed from "FILENAME > "file.log"; next}1 ' file.csv > newfile.csv which will create your file.log as specified and write ...


4

This should work for you: sed 's/"//g' files.csv | while IFS=, read orig new; do mv "$orig" "$new"; done Explanation: sed 's/"//g' files.csv : remove the quotes IFS=, : split the input on , while read orig new; do ... done : This will read each input line, split it on the value of $IFS (here a comma) and save the 1st field as $orig and the rest as ...


3

I had a script that I adjusted (good idea the (N+1)q part!) thanks to @chronitis comment and the SO answer: #! /bin/bash # N=10 M=20 P=2 Q=3 sed -n "$N,${M}p; $((M+1))q" $1 | cut -d, -f$P-$Q Save the file as for example cut_csv, make it executable and use as cut_csv file It can be made fancier by accepting the N,M,P,Q parameters as input etc, but I ...


3

Just tied this way, with one of the people that need to use this, and that way is the correct way, even when it show it as (.csv) that doesn't matter, when opening up in Ubuntu gedit - it is working like the Notepad and everything is correct. So even if you have the latest version of LibreOffice, that is still working, and that link is for Open Office, and ...


2

perl: $ perl -i.bak -F, -ane ' if ($F[0]+1 == $F[1] and $F[1]+1 == $F[2]) {warn "row $.: $_"} else {print} ' file.csv 2>file.log $ cat file.log row 7: 2,3,4,25,11 $ cat file.csv 4,6,18,23,26 5,12,19,29,31 2,5,13,16,30 9,10,24,27,32 4,5,10,19,22 4,6,8,10,25


1

This creates a CSV file with file name, time stamp and size for all files in /some/folder/ and its subfolders: find /some/folder -printf '"%P";"%Tc";"%s";\n' See the documentation for -printf in the manpage for find if you want to use other fields. Note that it doesn't work for file names containing " characters.


1

Part of the answer depend which kind of interface you want and the kind of output you require (quality, details, etc). If you are OK with a command line interface, the "classical" package for doing that is gnuplot, as stated in the comments. This is what I normally use for the first shot. I however think that PyXplot will normally give much nicer plots ...


1

Your file names should be escaped with quotes - MySQL considers them strings, so your MySQL block should be: LOAD DATA LOCAL INFILE '$RDDATEI' INTO TABLE bv_tmp_all FIELDS TERMINATED BY ';'; SELECT * FROM bv_tmp_all GROUP BY BAN INTO OUTFILE '$bv_out_distinct' FIELDS TERMINATED BY ';'; LOAD DATA LOCAL INFILE '$bv_out_distinct' INTO TABLE ...


1

You can combine awk and sed with a pipe sed -n '10,50p' file.csv | awk -F ';' '{print $3 $4}' 10 and 50 are rows. -F ';' is the field separator.(Semicolon in my example) $3 and $4 are the fields to show.


1

The following script using head and tail is able to print a part of a .csv file filtered through row and column's number. #!/bin/bash m="$2" n="$3" s="$4" t="$5" head -n "$n" "$1" | tail -n +"$m" | cut -d, -f "$s"-"$t" Save the above script as csv_view.sh and make it executable. chmod +x csv_view.sh where, m=row number where to begin n=row number ...


1

Thank you to @bodhi.zazen for the answer: #!/bin/bash # This file will gather who is information while IFS=, read url do whois $url &> "$url.txt" done < Urls.csv



Only top voted, non community-wiki answers of a minimum length are eligible