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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
03-29-2004, 04:13 PM
|
#1
|
Senior Member
Registered: Oct 2002
Distribution: Slackware
Posts: 1,348
|
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
|
|
|
03-29-2004, 04:36 PM
|
#2
|
Senior Member
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263
Rep:
|
if its of the form
and you want it to look like
then load the file into vim and type exactly
|
|
|
03-29-2004, 07:17 PM
|
#3
|
Senior Member
Registered: Oct 2002
Distribution: Slackware
Posts: 1,348
Original Poster
|
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 
|
|
|
03-29-2004, 07:20 PM
|
#4
|
Senior Member
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263
Rep:
|
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.
|
|
|
03-29-2004, 07:59 PM
|
#5
|
Senior Member
Registered: Oct 2002
Distribution: Slackware
Posts: 1,348
Original Poster
|
Wow!
That was cool.
Thanks so much. Can you recommend some links for learning Vi?
Steve
|
|
|
03-30-2004, 04:56 AM
|
#6
|
Senior Member
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263
Rep:
|
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.
|
|
|
03-30-2004, 11:06 PM
|
#7
|
Member
Registered: Mar 2004
Location: Upstate NY
Distribution: Slackware/YDL
Posts: 77
Rep:
|
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
|
|
|
03-31-2004, 06:31 AM
|
#8
|
Senior Member
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263
Rep:
|
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 04:36 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|