Empty quote char in FasterCSV

Discussion in 'Ruby' started by Romiras, Mar 19, 2014.

  1. Romiras

    Romiras Guest

    I have to generate a file with values separated with semicolon. There are empty values for which "" is unwanted.

    For example, this code
    FasterCSV.generate({:col_sep => ";"}) { |csv| csv << ["another", "", "row"] }

    generates the following output:

    As you see, "" is unwanted in output. The wanted output is

    I tried to accomplish it using :quote_char with the following code:
    FasterCSV.generate({:col_sep => ";", :quote_char=>""}) { |csv| csv << ["another", "", "row"] }

    Is there a way to omit empty ""?
    Romiras, Mar 19, 2014
    1. Advertisements

  2. Romiras

    Romiras Guest

    Damn. I was pretty close to solution.

    I supposed just to use nil instead of empty string...

    Now it works for me.

    Thank you, Michael.
    Romiras, Mar 20, 2014
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.