Jump to content

Prepending Each Line of a LARGE Text File?


Recommended Posts

How does that solve the OPs problem, as he wants to append every line with the new data?

 

Sorry, I misread.

There is a cool tool call TEXTools that can do this stuff by dos command line piping. I would assume it would be faster than autoit.

TEXTools is a powerful integrated collection of 50+ DOS filters that you
can easily combine together like building blocks, to form
"mini-programs", (called pipes) that process text for achieving various
goals.  It can be used interactively from the command prompt to quickly
handle ad hoc requests, or it can be called from batch file processes,
(even other programs) to handle more complex tasks. TEXTools can be used to:

* extract data from cumbersome log files
* organize lists
* customize text output from other programs
* reformat program source code
* automate manual processes
* count lines of text
* total values
* interface incompatible software systems
* build reports
* convert exported text for use by other software packages
* perform textfile searches
* perform base conversions
* format mailing lists for printing
* search for and/or remove duplicates
* convert tabular data to delimited and vice versa
* construct tables
Link to comment
Share on other sites

 

Sorry, I misread.

There is a cool tool call TEXTools that can do this stuff by dos command line piping. I would assume it would be faster than autoit.

TEXTools is a powerful integrated collection of 50+ DOS filters that you
can easily combine together like building blocks, to form
"mini-programs", (called pipes) that process text for achieving various
goals.  It can be used interactively from the command prompt to quickly
handle ad hoc requests, or it can be called from batch file processes,
(even other programs) to handle more complex tasks. TEXTools can be used to:

* extract data from cumbersome log files
* organize lists
* customize text output from other programs
* reformat program source code
* automate manual processes
* count lines of text
* total values
* interface incompatible software systems
* build reports
* convert exported text for use by other software packages
* perform textfile searches
* perform base conversions
* format mailing lists for printing
* search for and/or remove duplicates
* convert tabular data to delimited and vice versa
* construct tables

It's $39.  The OPs code fixed to open the file for writing and passing a file handle instead of a filename results in a 500mb file created with each line modified from another file in 37 seconds on my work laptop.  If there was a free tool that could do this significantly faster, perhaps it would be a good alternative, but I doubt it will be any faster if it is even capable of performing the task, and if it is, I doubt it would be $39 worth the faster, but that's just my opinion.

Link to comment
Share on other sites

It's $39.  The OPs code fixed to open the file for writing and passing a file handle instead of a filename results in a 500mb file created with each line modified from another file in 37 seconds on my work laptop.  If there was a free tool that could do this significantly faster, perhaps it would be a good alternative, but I doubt it will be any faster if it is even capable of performing the task, and if it is, I doubt it would be $39 worth the faster, but that's just my opinion.

 

I agree. I'm happy waiting for the 37 seconds rather than spending $39 for something that might produce the same result, even if it were a couple seconds faster. Not to mention that I prefer to use native code rather than calling to an external program; although, I do appreciate MarkRobbins' suggestion.

Link to comment
Share on other sites

Do some study on UnixTools for Windows. There are several tools that can do what you need.

I would probably use AWK which is real powerful and quite simple to use once you grasp it's logic. Yes it's (yet) another language to learn but for certain things and especially text-crunching on (VERY) large files, it's a good tool.

A very simple example:

awk "{ print $0 'Text to append after each line' }" < input > output

 

which will work as a 1-liner from Dos.

If more logic is involved, Perl is another great tool, probably better than AutoIT for serious text crunching (did not compare performance though!).

All above are freeware, with source.

I am just a hobby programmer, and nothing great to publish right now.

Link to comment
Share on other sites

  • Moderators

The OP has already been provided a very workable answer in AutoIt, and has said the time taken for danwilli's answer is agreeable. What value is there in pointing him to two completely different tools to learn?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...