Results 1 to 3 of 3
hello all,
I am a bit at a lost here
I have a file with 5000 lines
it is a list of books authors, series and titles
all lines start ...
- 12-21-2010 #1Just Joined!
- Join Date
- Aug 2005
- Posts
- 5
create cvs from list text file
hello all,
I am a bit at a lost here
I have a file with 5000 lines
it is a list of books authors, series and titles
all lines start with the author names, than there is a dash (-) than the series name, a dash again and the title of the book
the problem I encounter is that sometime there is a series, sometime not, and as I try to enter this list in a database, I wanted to create a cvs file to import into mysql
ex:
A. A. Attanasio - Radix Tetrads 01 - Radix
A. A. Attanasio - Solis
the best would be to be able to add in the second line, a "space dash space" just after the author name, but how to make sure it does not do it to the first line as well
if I could separate all line with 2 dash, (grep ??) then I would be able to do a simple replace, and change the single dash into two
I will keep digging into it but I would really appreciate if someone would know of way to do it
thanks
reup
- 12-21-2010 #2Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Try this:
Code:awk -F "-" 'NF==2{$1=$1 "- -"}1' OFS= file
- 12-21-2010 #3Just Joined!
- Join Date
- Aug 2005
- Posts
- 5
Franklin52, thanks very much for your answers
I need to try it.
I have found a way as well (did not sleep las night) and it is probably not as elegant but it seems to work
then I grep out the bliblibliCode:sed -e 's/-/blablabla/1' -e 's/-/bliblibli/1' list.txt > newlist.txt
also the file with bliblibliCode:grep -v bliblibli newlist.txt > verygoodfilename.txt
therefore, I end up with 2 files, one with the series, one withoutCode:grep bliblibli newlist.txt > anothergoodname.txt
it is a lot of work but so little compare to a hand sorting
reup


Reply With Quote