Giter Site home page Giter Site logo

Comments (5)

Dijji avatar Dijji commented on August 24, 2024

I specifically didn't want new line characters to create multiple rows in Excel, simply because I wanted to test it on large input sets, and creating additional rows made verification significantly harder.

Replacing " with "" might well make sense, though I would need to test it.

Do you have any specific reason for these requests?

Dijji

from xstreader.

halueda avatar halueda commented on August 24, 2024

IMHO, exporting task should preserve as much information as possible.
Deleting newline changes meaning, especially original message header.

I understand about test, but excel and other CVS related tools can read without problem and
test with such tools is far better than checking with human eyes.

My patch was WIP and not checked, sorry.
Now I have correct source code to solve this issue, and soon commit it.
It is checked by exporting folders and reading by excel. The forlders have >10,000 messages including plain text and HTML with multilingual text in Japanese.
--HAL

from xstreader.

fabien-gigante avatar fabien-gigante commented on August 24, 2024

I had the same need that @halueda, trying to preverse as much as possible all the values.

I believe the commit from @halueda is checking twice \n (instead of - I assume - checking \n and \r ) :

... value.Contains("\n") || value.Contains("\n") ...

Also for some reason, Excel doesn't open the CSV correctly, and requires the current locale separator instead of a plain comma. I'm not sure if Excel complies with the RFC 4180 with such a behavior. I had to locally modify the code like so to make it work for me. Even though this is probably not a change you want to incorporate officially (or through a setting only maybe).

        private void AddCsvValue(StringBuilder sb, string value, ref bool hasValue)
        {

            string comma = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator; // ",";
            if (hasValue) sb.Append(comma);
            if (value != null) 
            {
                 bool escape = value.Contains(comma) || value.Contains("\"") || value.Contains("\r") || value.Contains("\n");
                 if (escape) value = "\"" + value.Replace("\"", "\"\"") + "\"";
                 sb.Append(value);
            }
            hasValue = true;
        }

from xstreader.

Dijji avatar Dijji commented on August 24, 2024

Thank you for reminding me of the work done by halueda on multilanguage support when exporting to csv files. I should have merged the changes long ago. So now I have. However, I did not include the changes to add the body in some form to the csv file, as there are other, higher fidelity, ways to get this information already.

I have also incorporated your change to make the comma culturally sensitive in the changes for the next release. I don't mind diverging somewhat from an RFC that is observed strictly almost nowhere, as I think that Excel is almost certainly the dominant scenario for reading such files.

Thank you for raising the issues that you encountered, and fixing them too!

Dijji

from xstreader.

Dijji avatar Dijji commented on August 24, 2024

Changes released as version 1.11

from xstreader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.