1
$\begingroup$

enter image description hereHello,

I have a problem with importing .txt file which uses "," as decimal as well as field operator. I need to convert numbers with decimal comma to decimal point and create field operator to separate them. I tried to use command FieldSeparators and NumberPoint but I think there is no chance Mathematica can understand and distinguish between Number and Field Sparators.

Section1 = Import["C:\\Desktop\\Section1.TXT",{"Data"},"FieldSeparators"->","];
TimeSection = Section1[[3;;Length[Section1],1]];
CurrentSection1 = NumberForm[Section1[[3;;Length[Section1],7]],NumberPoint->","]

And all I got is what you can see on the pic. Any one knows how to fix this issue?

Thank you for your help.

I cannot change the format for decimal point before import since the txt is generated by electric quality-meter device and exported via speacial program and I have many of these txt files so If I changed it manually it would be very time-consuming.

Here is the link for my .txt: https://pastebin.com/raw/udcFTuG7

Update: I have figured out that actually the field separator is not in form "," but has extra space behind comma hence ", " so I wrote "FieldSeparators"->", " but I got the same result.

$\endgroup$
7
  • 1
    $\begingroup$ Is there any way for the original file to not use the comma as a field separator? $\endgroup$ Commented Feb 9, 2021 at 12:22
  • $\begingroup$ I don't think there is an easy way or at least there is no way to do it automatically. These results are generated from electric quality-meter device and I can only open in a special software which can export data in this txt way and I cannot change the format. Device is designed for european market so it uses decimal commas. I could do it maybe manually in csv format or manually change comma for point using ctrl+h in notepad but since I have tons of these txt files it would be very time-consuming. $\endgroup$
    – Vocis
    Commented Feb 9, 2021 at 12:31
  • 1
    $\begingroup$ OK, I just wanted to confirm that your situation forces you to have commas pull double-duty (which is really unadvisable otherwise). I think you should include this extra information in your question. $\endgroup$ Commented Feb 9, 2021 at 12:33
  • $\begingroup$ I updated my question. Anyway, I think the solution could be that actually between every number there is as fieldseparator comma and space therefore it is ", " not just "," so it might be used for "FieldSeparators"->", " but it doesn't work or I may have used it wrongly. $\endgroup$
    – Vocis
    Commented Feb 9, 2021 at 12:44
  • 3
    $\begingroup$ @Vocis in the file you linked the fields are NOT separated by commas, but instead by what appears to be tabs, or spaces perhaps. I think the commas you see are list delimiters in Mathematica, but they are not there in the original file. Try to import the file as “TSV”, ie tab-separated values. $\endgroup$
    – MarcoB
    Commented Feb 9, 2021 at 13:45

1 Answer 1

1
$\begingroup$
data=Import["https://pastebin.com/raw/udcFTuG7",{"TSV","Data"}, NumberPoint -> ","]
ListPlot[Transpose@data[[3;;]]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.