Results 1 to 5 of 5
i need a simple text parser which can parse a data file created by a softwre so that i can export it to my mysqldb,, datafile created as one record ...
- 07-29-2008 #1Just Joined!
- Join Date
- Jul 2008
- Posts
- 3
need a text parser
i need a simple text parser which can parse a data file created by a softwre so that i can export it to my mysqldb,, datafile created as one record per line with different number of fields.
e.g datafile contains following.
a=1, b=3, c=4
a=1, c=55, d=abcd
a=5, b=hello, c=99, d=help
now i want to parse them as
1,3,4
1,55,abcd
5,hello,99,help
i want to remove field name and make data as comma seperated so that i can export them to my db. or anyother way to export these fields to mysql where field names are same as a,b,c,d.
a,b,c and d are fields.
- 07-29-2008 #2
look on the web for awk tutorials, you should find what you need
- 07-30-2008 #3Just Joined!
- Join Date
- Jul 2008
- Posts
- 3
I tred awk but i dont know how to use multi dimentioal arrays for split. I can split single value e.g a=1 but dont knw how to with multiple values in single record.
any sugession ?
- 07-30-2008 #4Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
A simple sed line should do:
Code:sed -e 's/ *[a-zA-Z]*=//g' filename.txt
- 07-30-2008 #5Just Joined!
- Join Date
- Jul 2008
- Posts
- 3
i got rid of the left side and got the results with awk and sed using
sed 's/[^,]*=//g'
but one poblem. On monotor it displays correclty but when at the end i try ti put them in a file using >> filename , there i am getting "\" after every field and that file 'filename'.
eg.
12\,hello\,99
2\,22\,abcd
how to remove the trailing '\'


Reply With Quote