I am trying to duplicate the below data 1 million times and want to write to file.
row1,Test,2.0,1305033.0,3.0,sdfgfsg,2452345,sfgfsdg,asdfgsdfg,Gasdfgfsdgh,sdgh,sdhd sdgh,sdgh,sdgh,,sdhg,,sdgh,,,,,,,sdgh,,,,,,,,,05/12/1954,,,,,,sdghdgsh,sdfhgd,,12/25/1981,,,,12/25/1981,,,,,,,,,,,,,sdgh, dsghgh; sdgh,,,,,1.0,sdfsdf,sfgggf,34f
each time I want to update the first column to no of records, so my second row will be
row2,Test,2.0,1305033.0,3.0,sdfgfsg,2452345,sfgfsdg,asdfgsdfg,Gasdfgfsdgh,sdgh,sdhd sdgh,sdgh,sdgh,,sdhg,,sdgh,,,,,,,sdgh,,,,,,,,,05/12/1954,,,,,,sdghdgsh,sdfhgd,,12/25/1981,,,,12/25/1981,,,,,,,,,,,,,sdgh, dsghgh; sdgh,,,,,1.0,asrg,awrgtwag,245sfgsfg
I tried using String builder, I am not able to append more than 10,000 rows.... The program becomes very slow....
Any suggestions...
I'm fine trying to write code in other languages
The below is the code snippet which prepares the data to write to the file and in my app I'll get data as Object[]
private static void writecsv(Map<String, Object[]> data) throws Exception{
Set<String> keyset = data.keySet();
StringBuilder sb =new StringBuilder();;
for(int count=0; count < OUTPUT_RECORD_COUNT;count++)
{
for (String key : keyset)
{
Object[] objArr = data.get(key);
for (Object obj : objArr)
{
if(obj ==null)
obj=BLANK;
sb.append(obj.toString() + COMMA);
sb.toString();
}
sb.setLength(sb.length()-1);
sb.append(NEW_LINE);
}
}
System.out.print( sb.toString());
}