LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-29-2004, 04:13 PM   #1
Franklin
Senior Member
 
Registered: Oct 2002
Distribution: Slackware, WinXP, Windows 7
Posts: 1,253

Rep: Reputation: 55
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.

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
 
Old 03-29-2004, 04:36 PM   #2
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 50
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
 
Old 03-29-2004, 07:17 PM   #3
Franklin
Senior Member
 
Registered: Oct 2002
Distribution: Slackware, WinXP, Windows 7
Posts: 1,253

Original Poster
Rep: Reputation: 55
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
 
Old 03-29-2004, 07:20 PM   #4
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 50
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.
 
Old 03-29-2004, 07:59 PM   #5
Franklin
Senior Member
 
Registered: Oct 2002
Distribution: Slackware, WinXP, Windows 7
Posts: 1,253

Original Poster
Rep: Reputation: 55
Wow!

That was cool.

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

Steve
 
Old 03-30-2004, 04:56 AM   #6
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 50
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.
 
Old 03-30-2004, 11:06 PM   #7
kooch
Member
 
Registered: Mar 2004
Location: Upstate NY
Distribution: Slackware/YDL
Posts: 77

Rep: Reputation: 15
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
 
Old 03-31-2004, 06:31 AM   #8
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 50
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
NEED AWNSER QUICK how do I save editing a text file in Konsole? DDRfreak2 Mandriva 1 08-18-2005 06:09 PM
Editing text file in Shell - Konsole (SuSE 9.1) Ree Linux - Newbie 5 10-03-2004 11:48 AM
Booting to VGA or text mode without editing config file mattman1081 Linux - Newbie 6 02-10-2004 08:36 PM
Some techniques for text file editing ganninu Programming 17 10-09-2003 05:34 PM
Editing a text file in shell Lotmr Linux - Software 5 06-24-2003 12:12 PM


All times are GMT -5. The time now is 01:58 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration