Remove line from .txt / convert .pdf to .txt /format cell

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Snickers76
Newbie
Posts: 12
Joined: Mon Mar 10, 2008 6:26 pm

Remove line from .txt / convert .pdf to .txt /format cell

Post by Snickers76 » Thu May 29, 2008 2:28 pm

I have a large text document from which I am importing particular lines of text into excel; however, I need to delete or completely remove any and all lines that begin with one of the following:

[code]
Page

Task Name Start Finish
"blank line with no text written to it. like a CRLF"
[/code]

After the lines are removed, I can't have any empty lines.

How can one convert a .pdf file to a .txt file using Macro Scheduler?

When using the following code, The combined lines are entered as one sentence into the Excel cell. Is it possible to add a soft return, such as ALT-ENTER would do when working within Excel?

[code]
//where JNSLine=starting line of corresponding job number data
//subStoreStatus------------------------------------subStoreStatus
SRT>subStoreStatus
ReadFile>%NPFilepath%,inFile
Separate>inFile,CRLF,lines
Let>k=%JNSLine%-1
Repeat>k
Let>k=k+1
Let>this_line=lines_%k%
Position>#,this_line,1,p
If>p=1
//found line starting with #,
If>combined
//output combined to Excel
DDEPoke>Excel,%ExcelFilepath%,R%RowCount%C3,%combined%
DDEPoke>Excel,%ExcelFilepath%,R%RowCount%C8,%date%
END>subStoreStatus
Endif
//reset combined
Let>combined=
Else
Let>combined=%combined% %this_line%
Endif
Until>k=lines_count
END>subStoreStatus
[/code]

Why do the excel cells not expand when data is inserted into them? I have text wrap on for each cell.
Last edited by Snickers76 on Thu May 29, 2008 3:21 pm, edited 1 time in total.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Thu May 29, 2008 3:21 pm

1. You can loop through the text file, writing the "keeper" lines to a new file, and skipping by the "throw away" lines.

2. You can use Macro Scheduler to call a PDF utility program that will convert PDF to text. See PDF995 Suite as an example at http://www.pdf995.com
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Snickers76
Newbie
Posts: 12
Joined: Mon Mar 10, 2008 6:26 pm

Post by Snickers76 » Thu May 29, 2008 3:26 pm

Bob Hansen wrote:1. You can loop through the text file, writing the "keeper" lines to a new file, and skipping by the "throw away" lines.
Thanks Bob, that sounds effective enough. I'll give that a try and see what it comes up with.

EDIT: Ok, I looped it but i cant seem to omit the blank line nor the odd character.
Bob Hansen wrote:2. You can use Macro Scheduler to call a PDF utility program that will convert PDF to text. See PDF995 Suite as an example at http://www.pdf995.com
I can manually convert my pdf to a text file. However, instead of opening my pdf file and manually converting it, I was wondering if it was possible to convert it using direct MScheduler code instead of the macro repeating the actions I would normally take if i were doing it manually

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Thu May 29, 2008 3:54 pm

There's no magic bullet/simple algorithm that will convert a pdf to text so, while it could surely be done, it would be a huge amount of work to write a robust macroscheduler routine for this purpose. Better to automate someone else's program as Bob suggests. There are plenty of command line pdf-text converters which would be very easy to integrate into a macro.

Snickers76
Newbie
Posts: 12
Joined: Mon Mar 10, 2008 6:26 pm

Post by Snickers76 » Thu May 29, 2008 4:06 pm

[quote="Me_again"]There's no magic bullet/simple algorithm [...]very easy to integrate into a macro.[/quote]

The whole office will be using this so I, for the time being, will just manually convert the pdf to text.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Thu May 29, 2008 5:25 pm

Did a Google for "free pdf to text command line" and got over 500,000 returns. You should be able to find one that will save you a lot of work.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Snickers
Macro Veteran
Posts: 150
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Thu May 29, 2008 6:12 pm

I use the full adobe version. I open the pdf and then click file/save as text. I was hoping to avoid this step without the user having to open the pdf file; however, I'm reluctant to use any free software on the office computers. I will take some more time tonight to give these pdf-text commandline programs a look.

Thank you for recommending these.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Fri May 30, 2008 3:45 am

Check the full Adobe documentation for the ability to make the text from a command line vs. opening Adobe. What version are you using? I don't have access right now, but seem to recall that was possible.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Snickers
Macro Veteran
Posts: 150
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Fri May 30, 2008 1:06 pm

Bob, I'm using adobe standard 6.0 but have access to the new one if -->absolutely<-- necessary. I would like it work within the confines of 6.0 if possible. We only have 5 licenses left on the new adobe.

edauthier
Pro Scripter
Posts: 84
Joined: Sun Apr 13, 2003 1:26 pm
Location: USA

Post by edauthier » Fri May 30, 2008 3:29 pm

Why do the excel cells not expand when data is inserted into them? I have text wrap on for each cell.
I am wondering if you resolved this issue. Do you mean to say that the data is getting truncated or is it simply a display issue that you are writing about?

Snickers
Macro Veteran
Posts: 150
Joined: Thu Dec 09, 2004 3:01 pm
Location: Somewhere in TX

Post by Snickers » Fri May 30, 2008 4:30 pm

edauthier wrote:
Why do the excel cells not expand when data is inserted into them? I have text wrap on for each cell.
I am wondering if you resolved this issue. Do you mean to say that the data is getting truncated or is it simply a display issue that you are writing about?
This was an issue within excel. It was intermittent for some unknown reason. Some cells were auto sizing while others were not. The excel sheet was brand new, so I had done no formatting to it; however, all cells were not acting the same. I simply selected all excel cells and formated the rows to "autofit".

This issue has dissappeared now.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts