Skip to main content
Formatting.
Source Link
Shawn
  • 54.4k
  • 3
  • 30
  • 75

I have the following command:

echo "column1, column2, column3" > test.csv && cat data.json | jq -r '. | [.["column1"], .["column2"], .["column3"]] | @csv’ >> test.csv

echo "column1, column2, column3" > test.csv &&
cat data.json | jq -r '. | [.["column1"], .["column2"], .["column3"]] | @csv’ >> test.csv

itIt creates a column headings and the data from data.jsondata.json. I

I am trying to also add it where for example it only would pull data that contains the words ("abc""abc") from column3column3.
I added:

|select(.column3| startswith ('ab'))

I added |select(.column3| startswith ('ab')) so the full command is:

echo "column1, column2, column3" > test.csv && cat data.json | jq -r '. | [.["column1"], .["column2"], .["column3"]] |select(.column3| startswith ('ab')) | @csv’ >> test.csv

echo "column1, column2, column3" > test.csv &&
cat data.json | jq -r '. | [.["column1"], .["column2"], .["column3"]] |select(.column3| startswith ('ab')) | @csv’ >> test.csv

but I get the following error: -bash: syntax error near unexpected token `('

-bash: syntax error near unexpected token `('

my json.data looks like this: { "column1": "hello", "column2": "bye", "column3": "abc" }

{
      "column1": "hello",
      "column2": "bye",
      "column3": "abc"
}

How do I parse column3column3? Not sure what I am doing wrong. Thank you!

I have the following command:

echo "column1, column2, column3" > test.csv && cat data.json | jq -r '. | [.["column1"], .["column2"], .["column3"]] | @csv’ >> test.csv

it creates a column headings and the data from data.json. I am trying to also add it where for example it only would pull data that contains the words ("abc") from column3.
I added:

|select(.column3| startswith ('ab'))

so the full command is:

echo "column1, column2, column3" > test.csv && cat data.json | jq -r '. | [.["column1"], .["column2"], .["column3"]] |select(.column3| startswith ('ab')) | @csv’ >> test.csv

but I get the following error: -bash: syntax error near unexpected token `('

my json.data looks like this: { "column1": "hello", "column2": "bye", "column3": "abc" }

How do I parse column3? Not sure what I am doing wrong. Thank you!

I have the following command:

echo "column1, column2, column3" > test.csv &&
cat data.json | jq -r '. | [.["column1"], .["column2"], .["column3"]] | @csv’ >> test.csv

It creates a column headings and the data from data.json.

I am trying to also add it where for example it only would pull data that contains the words ("abc") from column3.

I added |select(.column3| startswith ('ab')) so the full command is:

echo "column1, column2, column3" > test.csv &&
cat data.json | jq -r '. | [.["column1"], .["column2"], .["column3"]] |select(.column3| startswith ('ab')) | @csv’ >> test.csv

but I get the following error:

-bash: syntax error near unexpected token `('

my json.data looks like this:

{
      "column1": "hello",
      "column2": "bye",
      "column3": "abc"
}

How do I parse column3? Not sure what I am doing wrong.

added 118 characters in body
Source Link
artemisia480
  • 125
  • 2
  • 3
  • 8

I have the following command:

echo "column1, column2, column3" > test.csv && cat data.json | jq -r '. | [.["column1"], .["column2"], .["column3"]] | @csv’ >> test.csv

it creates a column headings and the data from data.json. I am trying to also add it where for example it only would pull data that contains the words ("abc") from column3.
I added:

|select(.column3| startswith ('abc''ab'))

so the full command is:

echo "column1, column2, column3" > test.csv && cat data.json | jq -r '. | [.["column1"], .["column2"], .["column3"]] |select(.column3| startswith ('abc''ab')) | @csv’ >> test.csv

but I get the following error: -bash: syntax error near unexpected token `('

my json.data looks like this: { "column1": "hello", "column2": "bye", "column3": "abc" }

How do I parse column3? Not sure what I am doing wrong. Thank you!

I have the following command:

echo "column1, column2, column3" > test.csv && cat data.json | jq -r '. | [.["column1"], .["column2"], .["column3"]] | @csv’ >> test.csv

it creates a column headings and the data from data.json. I am trying to also add it where for example it only would pull data that contains the words ("abc") from column3.
I added:

|select(.column3| startswith ('abc'))

so the full command is:

echo "column1, column2, column3" > test.csv && cat data.json | jq -r '. | [.["column1"], .["column2"], .["column3"]] |select(.column3| startswith ('abc')) | @csv’ >> test.csv

but I get the following error: -bash: syntax error near unexpected token `('

How do I parse column3? Not sure what I am doing wrong. Thank you!

I have the following command:

echo "column1, column2, column3" > test.csv && cat data.json | jq -r '. | [.["column1"], .["column2"], .["column3"]] | @csv’ >> test.csv

it creates a column headings and the data from data.json. I am trying to also add it where for example it only would pull data that contains the words ("abc") from column3.
I added:

|select(.column3| startswith ('ab'))

so the full command is:

echo "column1, column2, column3" > test.csv && cat data.json | jq -r '. | [.["column1"], .["column2"], .["column3"]] |select(.column3| startswith ('ab')) | @csv’ >> test.csv

but I get the following error: -bash: syntax error near unexpected token `('

my json.data looks like this: { "column1": "hello", "column2": "bye", "column3": "abc" }

How do I parse column3? Not sure what I am doing wrong. Thank you!

added 207 characters in body
Source Link
artemisia480
  • 125
  • 2
  • 3
  • 8

I have the following command:

echo "column1, column2, column3" > test.csv && cat data.json | jq -r '. | [.["column1"], .["column2"], .["column3"]] | @csv’ >> test.csv

it creates a column headings and the data from data.json. I am trying to also add it where for example it only would pull data that contains the words ("abc") from column3.
I added:

|select(.column3| startswith ('abc'))

so the full command is:

echo "column1, column2, column3" > test.csv && cat data.json | jq -r '. | [.["column1"], .["column2"], .["column3"]] |select(.column3| startswith ('abc')) | @csv’ >> test.csv

but I get the following error: -bash: syntax error near unexpected token `('

How do I parse column3? Not sure what I am doing wrong. Thank you!

I have the following command:

echo "column1, column2, column3" > test.csv && cat data.json | jq -r '. | [.["column1"], .["column2"], .["column3"]] | @csv’ >> test.csv

it creates a column headings and the data from data.json. I am trying to also add it where for example it only would pull data that contains the words ("abc") from column3.
I added:

|select(.column3| startswith ('abc'))

but I get the following error: -bash: syntax error near unexpected token `('

How do I parse column3? Not sure what I am doing wrong. Thank you!

I have the following command:

echo "column1, column2, column3" > test.csv && cat data.json | jq -r '. | [.["column1"], .["column2"], .["column3"]] | @csv’ >> test.csv

it creates a column headings and the data from data.json. I am trying to also add it where for example it only would pull data that contains the words ("abc") from column3.
I added:

|select(.column3| startswith ('abc'))

so the full command is:

echo "column1, column2, column3" > test.csv && cat data.json | jq -r '. | [.["column1"], .["column2"], .["column3"]] |select(.column3| startswith ('abc')) | @csv’ >> test.csv

but I get the following error: -bash: syntax error near unexpected token `('

How do I parse column3? Not sure what I am doing wrong. Thank you!

edited title
Link
artemisia480
  • 125
  • 2
  • 3
  • 8
Loading
Source Link
artemisia480
  • 125
  • 2
  • 3
  • 8
Loading