Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert DD/MM/YYYY to MM/DD/YYYY and HH:MM to HH:MM AM/PM
#4
this is an easier way to work with csv will take csv string or file  convert date and time to the formats you wanted also shows how to access each row and cell

Function datefunction2
Code:
Copy      Help
out 
//// just for demo purposes
str csv=
;25/4/2018,18:23 
;25/4/2018,16:23
;25/4/2018,04:23

/////
out csv 
out "------------------------------------------------------------"
;create ICsv variable and load data
ICsv x._create
x.FromString(csv);; comment out or remove this line  and use line 15 below to load from a  csv file
// also remove lines 4-10
//x.FromFile("path of csv file") load csv data from file
str cell1 cell2
int nr=x.RowCount
int nc=x.ColumnCount
int r c
for r 0 nr ;;for each row
,for c 0 nc ;;for each column
,,if(c=0)
,,,cell1=x.Cell(r c)
,,,DATE d(cell1)
,,,cell1.timeformat("{MM/dd/yyyy}" d)
,,,x.Cell(r c)=cell1
,,else
,,,cell2=x.Cell(r c)
,,,DATE d1(cell2)
,,,cell2.timeformat("{hh:mm tt}" d1)
,,,x.Cell(r c)=cell2
x.ToString(csv); 
out csv ;;show CSV

also check out this topic  as it is similar to yours  http://www.quickmacros.com/forum/showthr...p?tid=4987
also check http://www.quickmacros.com/help/User/IDP_ICSV.html for more info on ICsv interface

You can access  each column  in the csv file  then use tok to split it further .
need more info where your code is failing to help you further


Messages In This Thread
RE: Convert DD/MM/YYYY to MM/DD/YYYY and HH:MM to HH:MM AM/PM - by Kevin - 04-14-2018, 10:37 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)