Puzzled by first line in Excel behavior

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Randall
Junior Coder
Posts: 38
Joined: Fri Jan 13, 2012 4:39 am

Puzzled by first line in Excel behavior

Post by Randall » Mon Aug 12, 2013 9:13 pm

I initially used "XLCreate>" to create what I thought was a pure csv file, but after file creation, a hex editor showed that the file really was an xls file, regardless of the file suffix ending.

So I abandoned creating the Excel file this way and did the GnuWin command "touch myfile.csv" which does create an empty Excel csv file which "XLOpen" successfully tackled.

However now I find that when I write the first line to the file using the "XLSetCell" command, it does set the data correctly, but puts tabs between the fields. Huh??? I thought this was a csv file.

I then closed the file and reopened it again on the 2nd and subsequent passes and this time XLSetCell correctly sets the line as comma-delineated data which is what I wanted for the first line. Much to my amazement the first line is quoted and then the fields are tabbed afterwards to match.

Is there anyway to get the first line written correctly with comma "," characters, not TAB characters?

Thanks for your help here.

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Tue Aug 13, 2013 1:37 am

This is a part of a script I had written originally to create a CSV file & had no issues with it.

Code: Select all

//Sets File Path & Header Attrib's
Let>FilePath=C:\%COMPUTER_NAME%.csv
Let>Header=Asset,Machine SN,Username,OS Type,Machine Boot Time,Logon Time,IP Address [LAN],IP Address [WiFi],Location

//Checks For Existing File
IfFileExists>%FilePath%,StartCollection,CreateFile

//Creates File If It Doesn't Exist
Label>CreateFile
WriteLn>%FilePath%,WriteResult,%Header%
Goto>StartCollection

Label>StartCollection
You Could Also Read The File Once Done & Replace The TAB Character With A Comma.
FIREFIGHTER

Randall
Junior Coder
Posts: 38
Joined: Fri Jan 13, 2012 4:39 am

my fix

Post by Randall » Tue Aug 13, 2013 2:05 am

My fix was to create a small template csv file, with the data comma separated already. Then all I had to do was an XLOpen>file and append data to it.

When finished, since it was a pure CSV file, I simpled ignored the header line for good data.

Thank you for your reply.

I consider this question now closed.

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