LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Editing text file for import to a spread/database (http://www.linuxquestions.org/questions/programming-9/editing-text-file-for-import-to-a-spread-database-163901/)

Franklin 03-29-2004 04:13 PM

Editing text file for import to a spread/database
 
Hello all,

I have a large text file (10,000 lines) that I need import into a spreadsheet or database. It was presented to me in a formated style with page breaks and headers etc.

I have whittled it down to the following format:

Code:


0038            R&B USEN-4 PRIVATE
RVUs            STD CHG    896.00          0      66      59136.00          0    727    652465.00
0053            R&B USEN 4 PRIVATE RM REQUEST
RVUs            STD CHG    862.00          0      20      17240.00          0    147    127449.00
0054            USEN 4 PRIVATE DIFFERENTIAL
RVUs            STD CHG    35.00          0      20        700.00          0    147      5166.00
18003            OBSERVATION FIRST HOUR USEN 4
RVUs            STD CHG    322.00          0      86      27692.00          0    857    277024.00
18004            OBSERVATION EA ADDIT'L HOUR U4
RVUs            STD CHG    63.00          0    1846    116298.00          0  21672    1370457.00

Ideally, the lines beginning with "RVUs" should be appended to the end of the line above them, forming one line of data instead of two. The easiest way (I think) would be to select the RVU lines, delete them, pipe them into a new text document, then import each text file seperately. I just don't know how to do it. :confused:

Any help on which editor would be best for this or how to do this would be appreciated.

This seems like it should be simple, I've just never had to do this before so I not sure where to start.

TIA

kev82 03-29-2004 04:36 PM

if its of the form

Code:

A
B
A
B
...

and you want it to look like

Code:

AB
AB

then load the file into vim and type exactly
Code:

1ggqa0Jjq10000@a

Franklin 03-29-2004 07:17 PM

Thanks for the quick reply.

Just to clarify...

Load into VIM
shift : (for last line mode)

enter the folowing:

1ggqa0Jjq10000@a

where 1 means one (not small L) and 10000 means the last line (I exagerated ;) my last line is 8648)

My result

E492: Not an editor command: 1ggqa0Jjq8648@a

Sorry :scratch:

kev82 03-29-2004 07:20 PM

no :, just type exactly what i said. the number(8648) should be half the number of lines minus one, but anything above that is fine also.

Franklin 03-29-2004 07:59 PM

Wow!

That was cool.

Thanks so much. Can you recommend some links for learning Vi?

Steve

kev82 03-30-2004 04:56 AM

umm, im not sure, i cant remember how i learned. try running vimtutor, it will go over the basic commands. after that just google for vim, lots of things seem to come up.

kooch 03-30-2004 11:06 PM

Oh lord....I think you just caused me to convert to vi(m). I've been an emacs user for years because it was the first thing I learned. That is freaking awesome. Now I have to learn to use it :P

kev82 03-31-2004 06:31 AM

you can do exactly the same thing in emacs, something like
Code:

M-< C-x ( C-n M-^ C-n C-x ) C-u 10000 C-x e
my main reason for using vim is that i find it much easier to remember the keys, for what the majority of people want i would say they are both as capable as each other.


All times are GMT -5. The time now is 12:34 PM.