DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

DataFileSave error

Solved!
Go to solution

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.

0 Kudos
Message 1 of 10
(5,441 Views)

Does

 

Call DataFileSave("C:\Datas-Data\Example-Daten\ANG\H305\test.csv","CSV")

work? Which DIAdem version are you using?

0 Kudos
Message 2 of 10
(5,432 Views)

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>"&Delimiter&"</delimiter>" and "C:\Datas-Data\Example-Daten\ANG\H305\test.csv"?

 

Thanks

Sunil Padikar M

0 Kudos
Message 3 of 10
(5,429 Views)

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.

0 Kudos
Message 4 of 10
(5,421 Views)

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

 

0 Kudos
Message 5 of 10
(5,418 Views)

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.

0 Kudos
Message 6 of 10
(5,414 Views)

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")
0 Kudos
Message 7 of 10
(5,408 Views)

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

0 Kudos
Message 8 of 10
(5,394 Views)
Solution
Accepted by topic author sunilpadikar77

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, "&", "&amp;") & "</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.

0 Kudos
Message 9 of 10
(5,389 Views)

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

0 Kudos
Message 10 of 10
(5,381 Views)