Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have been searching for a few weeks now for solutions but can't find a clear way to do this.
There are a number of challenges because the column vales change in size for example row in a job/printout may have a a LENGTH value of 345 while a new row will have a LENGTH value of 2345 (please see example below)
To add to this the first few lines in the table in the printout have multiple fields in like this :
CUSTOMER: MRS. ELLIE BLOM

ORDER NO:                             JOB NO:


Ideally I would like to automate the procedure either using code or a script, the environment is windows.
The output is from a very old DOS program which controlled a cutting machine and works super fast but doesn't generate a properly formatted csv file which I'd like to use for my diy projects.

I would like help and/or advice to remove the junk ( all the extra print pcl codes and other characters), leaving behind only the human readable text and numbers so that I can end up with a properly formatted file.

I would also like to replace the blanks in the columns with a 0.
I was looking at the Javascript and also jQuery map command which may be a solution but I am only a hobbyist programmer.
Here is an output screen of the info after uploading the file to a webpage using javascript:
I hope some kind soul(s) can help me and/or shed some light here.

Thank you kindly
Den

Here is a sample of the desired result (which I would like to get properly formatted as a csv when downloaded ) :
                     ** CUTTING LIST **

CUSTOMER: MRS. ELLIE BLOM

ORDER NO:                             JOB NO:

NUMBER OF BOARDS REQUIRED: 3          BOARD SIZE: 2740 X 1820

TYPE OF MATERIAL: MEL WHITE 16MM 9X6  GRADE OF MATERIAL:

CUTTING FACTOR: 10                    GRAIN: N

LENGTH  WIDTH  NUMBER  EDGING(L) EDGING(W)  HOLES

  1080    300    6        1         1
   568    300    8        1
   568    100    6        1

  1080    300    1        1         1
   284   1080    1        1         1
   284    284    4        1         1

   720    450    2        1         1
   568    450    3        1
   568    100    2        1

   450    360    2        1         1
   568    450    2        1
   568    100    2        1

   870    560    2        1
   868    560    2        1
   868    100    3        1

   870    560    2        1
   568    560    2        1
   568    100    3        1

   178    594    1        2         2
   538    596    1        2         2         2



TOTAL EDGING REQUIRED: 44,792m        TYPE OF EDGING:



7/9/2022     3:30


Below is the link to the jsfiddle I created to upload the file and display it or print it and it also downloads a CSV file automatically once you upload a text file (input1.txt) which I am trying to upload here.
(I'm currently attempting to create a properly formatted csv from it, hence the question here.)
jsfiddle link
To get the above to work download the input1.txt file from here at Github Link and upload it in the jsfiddle example.

What I have tried:

Regex
SED
pcl2ascii
pcl to pdf
ghostscript
more, type commands
hex editor
been reading up on PCL and ESC/p
printing emulation
and many more.
Posted
Updated 12-Sep-22 10:47am
v8
Comments
merano99 12-Sep-22 13:36pm    
You write "environment is windows", but you tagged Linux an DOS?
denman0000 12-Sep-22 15:18pm    
That's correct. Did you read that the output is from a DOS app ? Which can of course be run as a vm or in an emulators on various platforms.
But no problem, if adding the tags will make the question clearer for people I shall add more tags although I'm almost sure this may be an exhaustive list.

1 solution

I can't see any data garbage or PCL codes in the text shown. It is not clear exactly what the original file looks like and what the desired result would be. All non-displayable codes would be very easy to omit with e.g. C or C++. Replacing with 0 would also be possible, but would make the file poorly readable by humans. This is in contrast to the wish to leave only human readable text and numbers. Spaces in columns should be replaced either by tabs or semicolons, not by 0. It would be good to link an original file here and specify exactly how it should look afterwards.
 
Share this answer
 
Comments
denman0000 11-Sep-22 21:06pm    
Hi merano99

Thank you so much for the reply :) I really appreciate it.
I was worrying about putting too much in the original question for fear of flooding the page here with yards of info but you are correct and I shall edit and update by adding more screens of output and attaching the original file too.
Regarding the 0's , they would be only necessary for the fields which are blank currently.
Please see edited and updated question.
Thanks again

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900