Quantcast
Channel: Extract info from file - Ask Ubuntu
Browsing all 5 articles
Browse latest View live

Answer by Sergiy Kolodyazhnyy for Extract info from file

Python solution#!/usr/bin/env pythonimport re,syswith open(sys.argv[1]) as fd: for line in fd: pattern=[ x for x in re.split('\|\|\||;',line) if 'CSQ' in x] if pattern:...

View Article



Answer by kos for Extract info from file

Using Perl:perl -F'\|\|\|' -lane '$, = "\t"; @f = split(/;|\|/, $F[1]); shift(@f); splice(@f, 5); print(@f)' file-F'\|\|\|': sets the input field separator to |||;-l: enables automatic line-ending...

View Article

Answer by Wayne_Yux for Extract info from file

This should work for you:cut -d"|" -f4,5,6,7,8 filename.txt | sed 's/;//g' | sed 's/|/\t/g'Example:$ echo "2 41620 . T G 100 PASS...

View Article

Answer by heemayl for Extract info from file

Let's use sed:sed -r 's/.*\|\|\|;(CSQ[^|]+)\|([^|]+)\|([^|]+)\|([^|]+)\|([^|]+)\|.*/\1\t\2\t\3\t\4\t\5/' file.txtpython is not fast at manipulating very large file, this would be much faster than...

View Article

Extract info from file

Is there an efficient way to parse a file like:2 41620 . T G 100 PASS...

View Article

Browsing all 5 articles
Browse latest View live




Latest Images