05-12-2015 05:47 AM
Hi,
i am exporting DAT File to CSV Using the commant "DataFileSave".but it throws the following error(See error attached).
Below is the code whith errors out.
FilePath = "C:\Datas-Data\Example-Daten\ANG\H305\test.csv"
Delimiter = ", "
FileParameters = "<filename>"&FilePath&"</filename><delimiter>"&Delimiter&"</delimiter>"
Call DataFileSave(FileParameters,"CSV")
Please help.
Solved! Go to Solution.
05-12-2015 06:45 AM
Does
Call DataFileSave("C:\Datas-Data\Example-Daten\ANG\H305\test.csv","CSV")
work? Which DIAdem version are you using?
05-12-2015 06:48 AM - edited 05-12-2015 07:02 AM
Hi AndreasK,
i did not try that. will give it a try.
i am using Diadem 2012.
What is the difference between "<filename>"&FilePath&"</filename><delimiter>"&Del
Thanks
Sunil Padikar M
05-12-2015 07:16 AM
DataFileSave without parameters uses
vbTab as delimiter
and a dot decimal point.
If you use the the XML parameters you are capable to change the default.
Option Explicit dim filePath FilePath = "C:\temp\test.csv" dim FileParameters FileParameters = "<filename>" & FilePath & "</filename><delimiter>,</delimiter><decimalpoint>.</decimalpoint>" Call DataFileSave(FileParameters,"CSV")
works with my DIAdem 2012. However if you try to save huge files your memory might exceed.
05-12-2015 07:36 AM
Hi AndreasK,,
i tried that as well. it did not work.
Same error.
i am using Diadem 2012 original code i posted works fine. i have a client in germany who is getting error.
any workaround to solve this issue?
Regards
Sunil
05-12-2015 08:06 AM
The feature didn't work in 2010.
If he is using 2012 it should work.
No idea what is going worng.
You need to create a script including the content of the portal that fails to get additonal information.
05-12-2015 10:01 AM
Just by the way: Germany would need semicolon as delimiter and comma as decimal point to load to excel.
Option Explicit dim filePath FilePath = "C:\temp\german_test.csv" dim FileParameters FileParameters = "<filename>" & FilePath & "</filename><delimiter>;</delimiter><decimalpoint>,</decimalpoint>" Call DataFileSave(FileParameters,"CSV")
05-13-2015 01:07 AM
Hi AndreasK,
you are correct. Is there a work around for this? because if i change delimeter to ";" and decimal seperator to "," for germany client, other client from us may get error.
any robust solution you know to fix this issue?
Many Thanks
Sunil Padikar M
05-13-2015 01:26 AM
There is no real robust solution.
While some people think csv means "comma seperated values",
Microsoft defined it as "character seperated values".
Here we come to the locale settings of the machine.
Having a look at DecimalSeparatorMap you will determine that the world is green
and that using comma as decimal point isn't that unusual.
So we are in a dilemma.
A possible solution might be using:
Option Explicit SaveToLocalCharacterSeperatedValues("C:\temp\test.csv") Sub SaveToLocalCharacterSeperatedValues(ByVal filePath) dim csvParams : csvParams = "<filename>" & replace(filePath, "&", "&") & "</filename>" if 0 = instr(CStr(1.1), ",") then csvParams = csvParams & "<delimiter>;</delimiter><decimalpoint>,</decimalpoint>" else csvParams = csvParams & "<delimiter>,</delimiter><decimalpoint>.</decimalpoint>" end if Call DataFileSave(csvParams,"CSV") end sub
but be aware of the fact, that the locale settings in VbScript might be changed. Which will make the approach fail.
05-13-2015 06:35 AM
Hi AndreasK,
i run the above code, it runs successfully in my diadem 2012. but same code errors out at DataFileSave in my clients Diadem 2012.
i am not understanding why it is hapenning so.
Regards,
Sunil Padikar M