Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escaping Issue & Console Window closes prematurely #547

Open
TacticalMask opened this issue Dec 21, 2021 · 2 comments
Open

Escaping Issue & Console Window closes prematurely #547

TacticalMask opened this issue Dec 21, 2021 · 2 comments

Comments

@TacticalMask
Copy link

TacticalMask commented Dec 21, 2021

FIRST ISSUE

  1. Version: 5.0.6
  2. v16.13.1

My JSON may contain segments like

' "text": "@AccountName1 \n@accountName2", '

from

        "id": <number>,
        "created_at": <number>,
        "text": "@accountName1 \n@accountName2",
        "owner": { ...

which is from a comment section. I assume the user is including a new line entry which registers as the '\n'. My problem is when I convert to csv, that '\n' causes an error in the output, such that:

Line X ends with ';"@AccountName1 '
Line X+1 starts with '@accountname2";'

Whereas in other areas it outputs as:
Line Y contains ';"@AccountName1 @accountname2";'
which is what I desire.

  1. My command is:
    json2csv -d ; --flatten-objects -i <input> -o <output>

I think in my research, this problem is referred to as an escaping issue? I've tried the -q and -Q commands to no avail. How do I resolve this issue?

SECOND ISSUE

I'm running the json2csv command as part of a batch file that I execute through Windows CMD. However, the json2csv command closes my console window.

  1. json2csv -d ; --flatten-objects -i <input> -o <output>
    ... this would process and output the relevant csv file, but the next command from the batch file never executes.

  2. @for %%d in (%cd%\#Results\*.json) do echo %%d && json2csv -d ; --flatten-objects -i %%d -o %%d.csv
    ... this would process, outputting the relevant csv files until the final step in the loop. The final json file in the target source gets converted to a csv file, but then the next command in my batch file is not run and the console window closes.

I'm not sure what is the cause of this.

@juanjoDiaz
Copy link
Collaborator

Hi @TacticalMask ,

I definitely seem like an escaping issue.
What do you mean when you say that some lines have the wrong new line but others done? What differences are there between line X and Y to produce the difference?

Can you provide some input data for me to replicate the issue?

@juanjoDiaz
Copy link
Collaborator

Regarding the console issue, it sounds like an issue on your script.
Have you script that json2csv is returning the correct exit code?
Are you doing any other check or action that might case the failure?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants