.TXT file conversion to .CSV/.XLSX

IBM's Sort Product, ICETOOL, ICEMAN and ICEGENER.
Post Reply
User avatar
dot1q3
Registered Member
Posts: 10
Joined: Tue Feb 09, 2021 10:36 pm

.TXT file conversion to .CSV/.XLSX

Post by dot1q3 »

hi -

I have a batch job that produce an output file as HLQ1.DATA.TXT. it looks something like this:

1234567890;00;1234
2345678901;00;1234
3456789012;00;2345
4567890123;00;2345
5678901234;00;3456

And I want to send this file as excel to a customer. The current process is:



1. use reflection FTP to desktop and open the txt file in excel and adjust the columns accordingly (insert sheet rows with names, insert another row for the title).
2. then email them this file as excel.


So I’m trying to automate step #2/3 in a JCL as additional steps. Step #2 I can use a few utility to send. It’s Step #1 I’m trying to do in a job.
User avatar
Anuj Dhawan
Founder
Posts: 2802
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: .TXT file conversion to .CSV/.XLSX

Post by Anuj Dhawan »

Excel files are not mainframe compatible, so you can not do it the way you are asking - instead you can create a comma or tab delimited text file or a HTML file, transfer that to your PC and import into Excel. And it sounds like that you are already doing.

I think your best bet can be:
  • Create the data in XML. That format can be used directly by Excel.
  • Create File with SLK extension on PC, that can also be used directly by Excel.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: .TXT file conversion to .CSV/.XLSX

Post by Robert Sample »

Many people don't realize that Excel formats are exceedingly complex -- the last time I looked at the Excel file specifications was several years ago and the document was over 1000 pages at that time. And since Excel formats are binary, you run into the issue of mainframe EBCDIC versus PC ASCII.

Also, you need to realize that "comma-delimited" for Excel can use other delimiters besides commas (such as the semicolon). So the data you posted is, literally, already in delimited format (just not comma-delimited).
(insert sheet rows with names, insert another row for the title).
Why not just add the information you want to your mainframe data set before sending it off? It's not usually that hard to add a title row to a text file on a mainframe (even programmatically).

If you truly want to get Excel data on the mainframe, then convince your management to purchase one of the software products that support Excel on the mainframe. Depending upon the size of your mainframe, the product might even cost less than $100,000 -- but again that depends upon the size of your mainframe. These products generally include a way to get the data from the mainframe to the PC.
User avatar
dot1q3
Registered Member
Posts: 10
Joined: Tue Feb 09, 2021 10:36 pm

Re: .TXT file conversion to .CSV/.XLSX

Post by dot1q3 »

thank you anuj & robert for your response.

@robert, when i rename the .txt file to .csv, and ftp it to my windows desktop. upon opening in excel directly, all the data is on column 1 instead of 3 separate columns. can i change this to 3 separate columns programmatically via some jcl utilities?
User avatar
dot1q3
Registered Member
Posts: 10
Joined: Tue Feb 09, 2021 10:36 pm

Re: .TXT file conversion to .CSV/.XLSX

Post by dot1q3 »

sorry for the newbie question but how do i add/insert a string at the beginning of a dataset.

for example input:

abcdef
afdafa
fadfas

output would be:

this is a line
this is another line
abcdef
afdafa
fadfas

i understand i can use a sort but not sure. any examples would be helpful
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: .TXT file conversion to .CSV/.XLSX

Post by Robert Sample »

@robert, when i rename the .txt file to .csv, and ftp it to my windows desktop. upon opening in excel directly, all the data is on column 1 instead of 3 separate columns. can i change this to 3 separate columns programmatically via some jcl utilities?
Leave it as a .txt file. When you open the .txt file, Excel invokes the text conversion utility and one of the things you can specify is the delimiter (and semicolon is one of the options).
User avatar
dot1q3
Registered Member
Posts: 10
Joined: Tue Feb 09, 2021 10:36 pm

Re: .TXT file conversion to .CSV/.XLSX

Post by dot1q3 »

Robert Sample wrote: Fri May 21, 2021 1:28 am
@robert, when i rename the .txt file to .csv, and ftp it to my windows desktop. upon opening in excel directly, all the data is on column 1 instead of 3 separate columns. can i change this to 3 separate columns programmatically via some jcl utilities?
Leave it as a .txt file. When you open the .txt file, Excel invokes the text conversion utility and one of the things you can specify is the delimiter (and semicolon is one of the options).
yes, i can leave it as is in .TXT and when opening excel will ask me to do the conversion....but the whole point is doing this on the mainframe side (to automate all the clicking on excel app) so the user won't have to do it.

OK, i'm able to have it in .CSV but some reason when i open up the CSV file in excel, the 2nd column that has '00' has been truncated to '0'. for example:

original input

1234567890;00;1234

output

1234567890 0 1234

any ideas how to change this?

also, on the z/os side, can i change the format of the cells to TEXT. it's default is GENERAL.
User avatar
Anuj Dhawan
Founder
Posts: 2802
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: .TXT file conversion to .CSV/.XLSX

Post by Anuj Dhawan »

Microsoft suggests to open .csv in excel like this: https://support.microsoft.com/en-us/off ... 8bafe41857
also, on the z/os side, can i change the format of the cells to TEXT. it's default is GENERAL.
This does not sound like, it's doable as it's a attribute governed by excel.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Rohit Jain
Registered Member
Posts: 16
Joined: Mon Oct 27, 2014 8:30 am

Re: .TXT file conversion to .CSV/.XLSX

Post by Rohit Jain »

You can send the file as "notepad" only or ".csv" file which looks like "notepad". We send them a lot and I have not see that the file is opened in excel by "double-click". We need to 'open it with excel".
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM DFSort, ICETOOL, ICEMAN, ICEGENER.”