Issues with converting .csv to .t6

Posted By: chtostoic

Issues with converting .csv to .t6 - 07/16/19 10:56

Hello

I'm trying to convert my .csv data to .t6, but it doesn't work as it should.
Using Chart gets errors and doesn't plot.

Chart compiling........... t6 AAPL_2007
Using AAPL_2007.t6
Warning 035: AAPL_2007 ticks overlap on 2007-01-03 14:31:00
Error 055: No bars generated

.csv format:
[Linked Image]

Converted .t6 looks fine in ZHistoryEditor:
[Linked Image]

My amendments in CSVtoHistory default file:
Code
#define SPLIT_YEARS

string InName = "AAPL_1M_12282006_28062019_UTC.csv";  // name of a single year CSV file
string OutName = "AAPL.t6";

string Format = ",%Y-%m-%d %H:%M:%S,f3,f1,f2,f4,f6";


Example of converted .t6 file: https://fex.net/s/dtrbtd2

Data is fine, without gaps.


Thanks in advance

P.S. I need to convert around 500 files from .csv to .t6, so I will be grateful for a hint how to automate this task.
Posted By: chtostoic

Re: Issues with converting .csv to .t6 - 07/16/19 11:46

Found the answer in another topic.

Originally Posted by AndrewAMD
Your csv is oldest to newest, but Zorro uses data from newest to oldest. Change your format string to indicate the reverse order.

Originally Posted by AndrewAMD
That works too. I was referring to adding a + sign to the front of the string, to indicate ascending order.



Added + sign resolved the issue
Code
string Format = "+,%Y-%m-%d %H:%M:%S,f3,f1,f2,f4,f6";



Still asking for a recommendation how to automate convertation of 500 .csv data files to .t6. Total newbie in Lite-C.

Thanks
Posted By: jcl

Re: Issues with converting .csv to .t6 - 07/16/19 14:46

If the names of the 500 files follow a convention, you can import them all with dataParse() in a loop.
Posted By: leohermoso

Re: Issues with converting .csv to .t6 - 01/31/22 22:31

Place all the files in the same dir and loop through them, like this:

Code
function convert_to_history(string filename)
{
	string InName = strf("D:\\Quotes\\Brasil\\DI\\%s",filename);
	if(!InName) return quit("No file"); 
	int Records = dataParse(1,Format,InName);
	printf("\n%d lines read",Records);

	string OutName = strx(InName,".csv",".t6");
	if(Records) dataSave(1,OutName);
	printf("\n%s",OutName);		
	
}

function main()
{
	Verbose = 7;
	  string file = file_next("D:\\Quotes\\Brasil\\DI\\*.csv"); // DIR WHERE THE FILES ARE
	while(true)
	{
		
		convert_to_history(file);
		dataNew(1,0,0);
		file = file_next(0);
		if(file == 0 || file == "0")
			break;

		

	}
	quit("done");

}
© 2024 lite-C Forums