I have 100’s of CSV files to import into a DB. The shell script to import the file requires 28 fields formatted as such:
HEADER,MTMP,ClientAccountID,AccountAlias,AssetClass,Symbol,UnderlyingSymbol,Strike,Expiry,Put/Call,ReportDate,PreviousCloseQuantity,PrevClosePrice,CloseQuantity,ClosePrice,TransactionMtmPnl,PriorOpenMtmPnl,Commissions,Other,Total,
The Original CSV file extracted from a 3rd party is delivered as follows:
“HEADER”,“MTMP”,“ClientAccountID”,“AccountAlias”,“AssetClass”,“Symbol”,“UnderlyingSymbol”,“Strike”,“Expiry”,“Put/Call”,“ReportDate”,“PreviousCloseQuantity”,“PrevClosePrice”,“CloseQuantity”,“ClosePrice”,“TransactionMtmPnl”,“PriorOpenMtmPnl”,“Commissions”,“Other”,“Total”
Manually, I can open the CSV file in Excel and then save as CSV and excel will automatically save with correct format.
I’ve been working various approaches and here is where I am at (which returns various errors)
---choose folder with source files, the another folder for the results
set Quellordner to choose folder with prompt "In which Folder are the source-files you want to process?"
set Zielordner to choose folder with prompt "In which Folder do you want me to store the results? (Do NOT choose the same folder!)"
set Quelldateien to list folder Quellordner without invisibles
set Zieldateien to list folder Zielordner without invisibles
tell application "Finder"
delete (every item of folder Zielordner)
end tell
repeat with Datei in Quelldateien
tell application "Finder"
set Quelldatei to (Quellordner as string)
set Zieldatei to (Zielordner as string) & "(M).csv"
open document file Quelldatei
tell application "Microsoft Excel"
activate
open Quelldatei
set Zieldatei to get full name of active workbook
save workbook as workbook Zieldatei filename Quelldatei file format CSV file format with overwrite
close workbooks
--quit
end tell
end tell
end repeat
If there is a way to cut out excel that’s even better.
Thanks for the help
DL
I running OS X 10.10 Yosemite, although it says 10.8 below
Model: Macbook Pro
Browser: Safari 537.76.4
Operating System: Mac OS X (10.8)