Im using Jupiter Notebook.
I need to open the csv file in a panda dataframe with the extention, but it doesnt work,it makes this error:
“Could not get current stack focus. This likely means that the Data Wrangler extension is not compatible with the VS Code version. Please file an issue on the Data Wrangler GitHub repository.”
So im using this code to read multiple csv files to different lists and after that reading them into panda dataframes:
import pandas as pd
import os
csv_files = []
csv_files_ipf = []
csv_files_ripf = []
csv_files_uipf = []
csv_files_ruipf = []
csv_files_ping = []
datapath = "*****" #the right one is writen on my code
for file in os.listdir(datapath):
if file.endswith('parsed.csv'):
if file.startswith('ipf'):
csv_files_ipf.append(os.path.join(datapath, file))
csv_files.append(os.path.join(datapath, file))
elif file.startswith('ripf'):
csv_files_ripf.append(os.path.join(datapath, file))
csv_files.append(os.path.join(datapath, file))
elif file.startswith('uipf'):
csv_files_uipf.append(os.path.join(datapath, file))
csv_files.append(os.path.join(datapath, file))
elif file.startswith('ruipf'):
csv_files_ruipf.append(os.path.join(datapath, file))
csv_files.append(os.path.join(datapath, file))
elif file.startswith('ping'):
csv_files_ping.append(os.path.join(datapath, file))
csv_files.append(os.path.join(datapath, file))
else:
print('File not found')
print(file)
df_ipf = {}
df_ripf = {}
df_uipf = {}
df_ruipf = {}
df_ping = {}
for file in csv_files_ipf:
try:
df_ipf[file] = pd.read_csv(file, on_bad_lines='skip')
except UnicodeDecodeError:
df_ipf[file] = pd.read_csv(file, encoding='ISO-8859-1', on_bad_lines='skip')
for file in csv_files_ripf:
try:
df_ripf[file] = pd.read_csv(file, on_bad_lines='skip')
except UnicodeDecodeError:
df_ripf[file] = pd.read_csv(file, encoding='ISO-8859-1', on_bad_lines='skip')
for file in csv_files_uipf:
try:
df_uipf[file] = pd.read_csv(file, on_bad_lines='skip')
except UnicodeDecodeError:
df_uipf[file] = pd.read_csv(file, encoding='ISO-8859-1', on_bad_lines='skip')
for file in csv_files_ruipf:
try:
df_ruipf[file] = pd.read_csv(file, on_bad_lines='skip')
except UnicodeDecodeError:
df_ruipf[file] = pd.read_csv(file, encoding='ISO-8859-1', on_bad_lines='skip')
for file in csv_files_ping:
try:
df_ping[file] = pd.read_csv(file, on_bad_lines='skip')
except UnicodeDecodeError:
df_ping[file] = pd.read_csv(file, encoding='ISO-8859-1', on_bad_lines='skip')
df_ipf[filename] #the filename path is writen in my code
at the end i am printing the table of the file(filename) and it prints it with no issue, but for some reason the extention of the data-wrangler does not open the table so that i can display all of the lines.
I have tried in another tab with a simpler code and it works…
dont know why it doest work with this code.