I need to export csv file to jason using script component. can anyone guide me how to do it.
I haven't do this trasaction so less knowledge of C# component. I cannot use T-SQL (JSON AUTO) also to convert the file to jason.
I tried but getting below error..
my data in csv
February 8, 2019, 5:26pm
why not try it out via powershell?
import-csv "SampleInput.csv" | ConvertTo-Json -Compress | Add-Content -Path "output.json"
[Execute Process Task] Error: In Executing "PowerShell.exe" "import-csv "C:\New folder\convertcsv.csv" | ConvertTo-Json -Compress | Add-Content -Path "C:\New folder\output.json"" at "", The process exit code was "1" while the expected was "0".
February 8, 2019, 5:42pm
what are you running this from?
February 8, 2019, 5:55pm
Get-Content -path "SampleInput.csv" | ConvertFrom-Csv -Delimiter ',' | ConvertTo-Json | Out-File "Booya.json"
I need to use SSIS service only ..no t-sql option for me..so i am executing this on execute process task
February 8, 2019, 6:43pm
Can you show us exactly how you have added that command in your SSIS
Also check this out
Get-Content -path "C:\New folder\convertcsv.csv" | ConvertFrom-Csv -Delimiter ',' | ConvertTo-Json | Out-File "C:\New folder\Booya.json"
it succeeded when ran in PowerShell..but failed in SSIS Execute procedure task
Thank you very much!! it worked!!!!
I have below json file data
first i need to convert it to csv and then need it again in json..
I tried online converter for json to csv it gives me below csv file
then I ran execute process task and got json file but its incorrect
not sure first jason to csv was wrong or execute process task went wrong..
February 8, 2019, 8:23pm
Is this honework or real life? Why do you have to convert back and forth?
What isbyour final goal in this ssis
Actually I am trying to build package that convert csv to json. and for that I need test file that's reason I am manually converting json file to csv first.. and to validate also..
February 8, 2019, 9:21pm
how did you try to convert that file from json to csv? what tool did yo use? anyways the result you are looking at are actually correct. look at your csv no column names.
I found this:
It shows how to convert a CSV file to JSON and is fairly simple. The Powershell code is also quite simple but I would call it differently. It is actually easier to call Powershell from a script component...you can do something like this:
using (PowerShell powerShell = PowerShell.Create())
// Source functions.
// Call function contained in sourced script above.
results = powerShell.Invoke();
When you add the script - it can be an actual file or the actual code with parameters defined...
may be.. thank you for helping me !! appreciated!!