evkruining
Technical User
Hi,
I would like to automatically convert a plain text file containing a playlist to a sql script to import the proper data into an existing table. I'm running a linux server with all these powerful built-in tools like awk, sed and grep but I don't know how to use them proper. I guess a fancy shell script could do the job. Any suggestions?
The filename is 63.txt with something like this:
01 This Is The Artist Name - And the Song
02 Another Artist - Bla-Di-Bla Song
03 Cool new Band - Sing Sing Sing
04 The Singer-Songwriter - I'll write you a new song
05 etc - etc etc
..
..
..
The resulting sql script should look like this:
INSERT INTO playlist VALUES (63, 01, 'This Is The Artist Name', 'And the Song');
INSERT INTO playlist VALUES (63, 02, 'Another Artist', 'Bla-Di-Bla Song');
INSERT INTO playlist VALUES (63, 03, 'Cool new Band', 'Sing Sing Sing');
INSERT INTO playlist VALUES (63, 04, 'The Singer-Songwriter', 'I'll write you a new song');
INSERT INTO playlist VALUES (63, 05, 'etc', 'etc etc');
..
..
..
Thanks in advance for your suggestions.
I would like to automatically convert a plain text file containing a playlist to a sql script to import the proper data into an existing table. I'm running a linux server with all these powerful built-in tools like awk, sed and grep but I don't know how to use them proper. I guess a fancy shell script could do the job. Any suggestions?
The filename is 63.txt with something like this:
01 This Is The Artist Name - And the Song
02 Another Artist - Bla-Di-Bla Song
03 Cool new Band - Sing Sing Sing
04 The Singer-Songwriter - I'll write you a new song
05 etc - etc etc
..
..
..
The resulting sql script should look like this:
INSERT INTO playlist VALUES (63, 01, 'This Is The Artist Name', 'And the Song');
INSERT INTO playlist VALUES (63, 02, 'Another Artist', 'Bla-Di-Bla Song');
INSERT INTO playlist VALUES (63, 03, 'Cool new Band', 'Sing Sing Sing');
INSERT INTO playlist VALUES (63, 04, 'The Singer-Songwriter', 'I'll write you a new song');
INSERT INTO playlist VALUES (63, 05, 'etc', 'etc etc');
..
..
..
Thanks in advance for your suggestions.