14 ===================================================================
16 ./Script_FormatCSV input_file FORMAT_input FORMAT_output > output_file
18 FORMAT: CSV_Nyse /implemented
19 CSV_Yahoo /implemented
20 MyCSV /by default, not implemented
22 dCSV_Bourso /not implemented, no use just modify output in Server
23 / to modify output of Server, temporary
25 ===================================================================
46 for i
in range(len(self.
ListCSV)):
51 print "%s %s,%.3f,%.3f,%.3f,%.3f,%i" %(dictCSV[
'date'],dictCSV[
'time'],dictCSV[
'open'],dictCSV[
'high'],dictCSV[
'low'],dictCSV[
'close'],dictCSV[
'volume'])
54 print "%s %s,%.3f,%i" %(dictCSV[
'date'],dictCSV[
'time'],dictCSV[
'value'],dictCSV[
'volume'])
62 for line
in self.file.xreadlines():
67 if status_data ==
False:
72 ret = string.find(line,
"Date;opening;High;Low;closing;Volume")
78 ret = string.find(line,
"Date,Open,High,Low,Close,Volume,Adj Close")
82 ret = string.find(line,
"#")
94 tabline=line.split(
";")
98 date_tmp=datetime.datetime.strptime( tabline[0],
"%d/%m/%y" )
100 dictCSV[
'date'] = date_tmp.strftime(
"%d-%m-%Y")
101 dictCSV[
'time']=
"00:00:00"
102 dictCSV[
'open']=float(tabline[1])
103 dictCSV[
'high']=float(tabline[2])
104 dictCSV[
'low']=float(tabline[3])
105 dictCSV[
'close']=float(tabline[4])
106 dictCSV[
'volume']=int(tabline[5])
110 tabline=line.split(
",")
115 date_tmp=datetime.datetime.strptime( tabline[0],
"%Y-%m-%d" )
120 dictCSV[
'date']=date_tmp.strftime(
"%Y-%m-%d")
121 dictCSV[
'time']=
"00:00:00"
122 dictCSV[
'open']=float(tabline[1])
123 dictCSV[
'high']=float(tabline[2])
124 dictCSV[
'low']=float(tabline[3])
125 dictCSV[
'close']=float(tabline[4])
126 dictCSV[
'volume']=int(tabline[5])
130 tabline=line.split(
",")
133 date_tmp=datetime.datetime.strptime( tabline[0],
"%d-%m-%y %H:%M:%S" )
134 dictCSV[
'date'] = date_tmp.strftime(
"%Y-%m-%d")
136 dictCSV[
'time'] = date_tmp.strftime(
"%H:%M:%S")
137 dictCSV[
'value'] = float(tabline[1])
138 dictCSV[
'volume'] = int(round(float(tabline[2]),0))
141 self.ListCSV.append(dictCSV)
149 self.ListCSV.reverse()
156 ListFormat= [
"CSV_Nyse",
"CSV_Yahoo",
"dCSV_Bourso",
"MyCSV",
"MydCSV" ]
159 Infile = open(sys.argv[1],
'r')
160 Format_in = sys.argv[2]
161 Format_out = sys.argv[3]
170 if ( ( Format_in
not in ListFormat )
or ( Format_out
not in ListFormat) ):
175 CSV =
CSV( Format_in, Format_out, Infile )