Hi:
Haven’t posted here for a while but I’m scripting again and am having problems with unicode text in a .csv file.
I have a long script that reads file names, looks up info in a data file based on a string in the file name and creates a line of text for each file. At the end, this text is saved in a .csv file. The problem is extra characters at the end of each line in the .csv file.
Here’s an example of the output in the .csv file. Everything is good except the characters at the end of each line. Each line should end with either “Alt1,” Back", or “Front”. Instead, there is a string beginning with “utxt” at the end of each line. What am I doing wrong?
S14_OL5959_634_a1.jpg,Plasmic Trench Jacket,OL5959_634,S14 Outerwear Outdoor,Women’s,Red Hibiscus,Alt1utxt¹
S14_OL5959_634_b.jpg,Plasmic Trench Jacket,OL5959_634,S14 Outerwear Outdoor,Women’s,Red Hibiscus,Backutxtï¬
S14_OL5959_634_f.jpg,Plasmic Trench Jacket,OL5959_634,S14 Outerwear Outdoor,Women’s,Red Hibiscus,Frontutxt∆
S14_OM5839_010_b.jpg,Refueler X-Train Short,OM5839_010,S14 Sportswear HXT,Men’s,Black,Backutxt»
Here’s the section of the script that assembles the file-related data into a list, copies that line to a master string as part of a repeat loop and finally, when the repeat is done, saves the master string as a .csv file.
---build a string with data corresponding to one file
set CSVStyleTotal to (CSVFileName & "," & CSVModelName & "," & CSVModelNumber & "," & "," & "," & CSVLightBox1 & "," & CSVLightBox2 & "," & "," & "," & "," & CSVcolor & "," & "," & "," & "," & CSVAltView)
--copy that string to the final .csv file
copy (return & CSVStyleTotal) to end of CSVStyleTotalMasterList
---pass on the complete data to be saved in the .csv file
set theText to CSVStyleTotalMasterList
-----------CREATE THE CSV FILE AND SAVE IT TO THE DESKTOP---------------
set theFilePath to (path to desktop as string) & "test.csv" as string
set theFileReference to open for access theFilePath with write permission
write theText to theFileReference starting at eof
close access theFileReference