I'm currently working on a script that converts a jsonl to csv format. However, upon running the code on visual studio code's terminal, I get the following error:
Traceback (most recent call last):
File "C:\Users\Natthanon\Documents\Coding 101\Python\test.py", line 24, in <module>
with open(r'C:\Users\Natthanon\Documents\Coding 101\Python\CSV', 'a' , newline='') as f:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Natthanon\\Documents\\Coding 101\\Python\\CSV'
This is my python script below. If anyone has any clue on why I am receiving the permission error as shown above, do let me know if there are any solutions to this. I'm quite new to Python and I hope someone experienced will be able to help me out with this issue. Thanks!
import glob
import json
import csv
import time
start = time.time()
#import pandas as pd
from flatten_json import flatten
#Path of jsonl file
File_path = (r'C:\Users\Natthanon\Documents\Coding 101\Python\JSONL')
#reading all jsonl files
files = [f for f in glob.glob( File_path + "**/*.jsonl", recursive=True)]
i=0
for f in files:
with open(f, 'r') as F:
for line in F:
#flatten json files
data = json.loads(line)
data_1=flatten(data)
#creating csv files
with open(r'C:\Users\Natthanon\Documents\Coding 101\Python\CSV', 'a' , newline='') as f:
thewriter = csv.writer(f)
#headers should be the Key values from json files that make Coulmn header
thewriter.writerow([data_1['header1'],data_1['header2']])