Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

Manipulating a large txt file

Sep 22, 2007 1:27PM PDT

Hi All,

I have a large txt file of 11,759 lines, which is going to form the basis of a database and needs to be layed out in the correct format.

It has 2 styles of entries:

As an example:

AGGM,Munda New Georgia,S,8,20,E,157,16,10,4593
AYCH,Chimbu,,,,,,,,

The finished txt file product needs to look like this:

AGGM,Munda New Georgia
AYCH,Chimbu

Can this be done in Notepad2?

Many thanks,

Chris

Discussion is locked

- Collapse -
Notepad2
Sep 22, 2007 8:12PM PDT

There seems to be many types of Notepad2 so it's difficult to say without knowing which version you have.

But in any case I am not sure any Notepad will be up to this job. Notepads are by design simple affairs, and people who develop their own versions of Notepad usually do so for specific tasks in mind.

Looking at what you want to achieve it would seem to be a simple Find and Replace procedure, so a Notepad might be ok, but with 11,000 lines, it could be a long task.

What happened when you tried your Notepad2?

Mark

- Collapse -
Notepad2
Sep 22, 2007 9:10PM PDT

Thanks Mark for the reply.

I managed to do a find and replace on the second entry as I just highlighted the eight commas, and in the replace box left blank.

Its the first entry thats going to be the problem as there are around 9,000 entries like this, but all have differing numbers (Co-Ordinates) on the end so I carnt see how you can do a find and replace.

The Notepad2 I have does do complex syntax in find and replace mode, BUT, you have to know the commands and the syntax, LoL A Perl script would do it also, but dont know Perl yet.

Cheers Chris

- Collapse -
What I would do.
Sep 23, 2007 8:18AM PDT

Use the comma-delimited input mode of your database. Almost all have. Then simply delete the last 8 columns from your database(table).

Even Excel (or OpenOffice Calc) is a fine tool to do this. Open csv-file, delete columns, save (as csv-file). And that's the text-file you want. Couldn't be simpler than that.

All you've got to realize: such a text file is commonly called a csv-file (comma separated variable). Nothing magic. Then rephrase the question as "I've got a csv-file and I'm only interested in the first two fields" for my database.

Any editor with support for regular expressions could do the job also if you define the right pattern(s). Here's one: http://www.editpadpro.com/editpadpro.html
But I don't think you need it.

Kees