All Questions

Tagged with
Filter by
Sorted by
Tagged with
-2votes
1answer
46views

Create a List from a string in Python

I am new to pyhon and i can't find a way to manipulate a string of mine into a List. I read a file that contain this exact output (it is one parameter of a csv file): [{a,b,c},{aa,bb,cc}] I want to ...
user avatar
  • 491
0votes
0answers
15views

Python3 parsing json file and writing to csv

I'm trying to parse a JSON file to CSV. I'm having trouble getting ONLY the values of the json object to appear in their corresponding columns instead of having the key AND value appear in each column ...
user avatar
0votes
0answers
9views

Is there a way to export multiple pandas Dataframes in different sheet names using "to_csv" [duplicate]

is there a way to export different Dataframes in one single csv "prediction_dataset.csv" file , but in different sheets . df1 --> sheet_1 df2 --> sheet_2 .. .. dfn --> sheet_n
user avatar
  • 27
0votes
3answers
62views

How to convert CSV to nested JSON in Python

I have a csv file in the following format: a b c d e 1 2 3 4 5 9 8 7 6 5 I want to convert this csv file to Nested JSON format, like this: [{"a": 1, "Purchase" : { ...
user avatar
0votes
2answers
33views

How do I convert a large XML file to a CSV file?

Because of the need to build the knowledge graph, I wanted to convert a 3.39GB XML data file to CSV format, but when I tried Python, my computer ran out of memory. The following code: import glob ...
user avatar
1vote
1answer
30views

Add header to CSV files only once using Python - that are creating live

So I am getting live JSON data from the stock market and creating CSV files correspondingly, for each csv file we need to add header. def data_csv(self, task): ExchangeInstrumentName = task["...
user avatar
0votes
0answers
10views

Appending multiple rows to csv in python for multiple nested lists

I have a function which iterates for loop over some data and output the list of items. eg: Output of function is :- ["A", "B", "C", "D"] ["E", :F"...
user avatar
2votes
1answer
36views

How to find size or shape of an tensorflow.python.data.ops.dataset_ops.MapDataset object, output of make_csv_dataset

Using make_csv_dataset we could read an CSV file to tensorflow dataset object csv_data = tf.data.experimental.make_csv_dataset( "./train.csv", batch_size=8190, num_epochs=1, ...
user avatar
  • 603
0votes
3answers
43views

How to convert dot to comma in floating point numbers in python module cx_Oracle?

Is it possible to download data to a csv file by the cx_Oracle module, so that the floating point numbers have a comma instead of a dot? I need this functionality to properly load the downloaded csv ...
user avatar
0votes
1answer
24views

Display the input from from the csv

with open("life-expectancy.csv") as life_expectancy: next(life_expectancy) output = [] years = input('Enter the year of interest: ') for data in life_expectancy: ...
user avatar
0votes
1answer
37views

append values to the new columns in the CSV

I have two CSV, one is the Master-Data and the other is the Component-Data, Master-Data has Two Rows and two columns, where as Component-Data has 5 rows and two Columns. I'm trying to find the cosine-...
user avatar
  • 71
0votes
1answer
31views

Finding a logic to map the values of two .tsv files

I am working on a problem where I have 2 .tsv files and one has been arranged wrongly with respect to the other one. When I scan the file , I noticed a pattern which I am unable to put it in terms of ...
user avatar
1vote
1answer
26views

invalid syntax in csv files ipython

these are my input as a csv file but I can not run my code in ipython because of invalid syntax error but I do not know what should I do? mandana,5,7,3,15 hamid,3,9,4,20,9,1,8,16,0,5,2,4,7,2,1 sina,0,...
user avatar
0votes
1answer
28views

AttributeError: 'NavigableString' object has no attribute 'keys' in Python

I am trying to dump the data from an array into the csv file but it gives the following error: AttributeError: 'NavigableString' object has no attribute 'keys' in python. The array has the data when I ...
user avatar
  • 73
0votes
0answers
24views

separate files from the csv file in python

I am trying to separate a huge csv file into no of text files. But I didn't this early by reading all the content in the file and then separate it. Now the thing is that " the csv file must be ...
user avatar
  • 57
0votes
0answers
31views

jinja2 template generate data from dictionary with loop and condition

I have one csv file which has few colums marked with .M as mandatory which will be passed to jinja template as it with no condition check . But for some columns i have to check for column heading and ...
user avatar
  • 21
0votes
0answers
30views

How to load certain portion of file into memory and write it on a file in Python?

I have a csv file which generates dataframe for every second and stores it in it. It will have millions of values. How to load only certain part. Like only first 5 MB. Then next 5 MB in a text file.. ...
user avatar
  • 57
0votes
1answer
40views

Which file format uses less memory in python?

I wrote the code for points generation which will generate a dataframe for every one second and it keeps on generating. Each dataframe has 1000 rows and 7 columns.. It was implemented using while loop ...
user avatar
  • 57
0votes
0answers
40views

Python: load data with multiple delimiter into multiple columns using column name from data

I have a text file with the below data. I want to create multiple files with this data. Input File format: "id","first_name|Andrew~last_name|Dowards~email|adowards@example.com~gender|...
user avatar
  • 1
-1votes
0answers
21views

How to add a new column and fill the object list in to a csv file by Python?

I want to add 3 new columns and combine a list of objects to an existing CSV file, then fill the list of objects according to the existing csv file: 1 {'polarity': 0.0, 'subjectivity': 0.0, '...
user avatar
  • 7
0votes
1answer
21views

How to add a column into a CSV file

I need to add a column to calculate the total amount of immigrants in Canada by AreaName in df_canada: df_canada = pd.read_csv('https://raw.githubusercontent.com/iikotelnikov/datasets/main/...
user avatar
0votes
1answer
23views

How to force GZIP to read file when CRC check fails

I'm reading a bunch of gzip compressed files in Python using the gzip module. Unfortunately some of them fail the CRC check, so I'm looking for ways to go around this problem. Looking around ...
user avatar
  • 29
0votes
0answers
48views

How to read Greek csv into pandas dataframe

I am trying to process a large csv file that contains Greek words. A sample of the data: Three column table, Greek (unicode) words in first and third column Or: FileID Word Num Normalized ...
user avatar
0votes
0answers
11views

How to convert multiple csv files into xlsx files within a directory

I am new to python and I am having trouble converting multiple csv files in a directory to xlsx files. If I convert a single file I have no problem but when I try to use a for loop and the glob ...
user avatar
  • 1
0votes
2answers
130views

Import data from csv file as variable for code in Python

I am trying to import a set of data from a CSV file to shorten my code in python, Before I try to use the CSV file as a variable, I have confirmed the code is working as below: csvone = pd.read_csv(&...
user avatar
1vote
0answers
17views

Reading google sheets as a data frame with columns that have commas in their values

Im trying to read a google sheet as a dataframe using this code: link = f'https://docs.google.com/spreadsheets/d/{google_id}/export?format=csv' r = requests.get(link) data = r.content df = pd....
user avatar
0votes
0answers
30views

pandas does not encode my csv file when reading it

I have a problem in the encoding when reading my csv file. I tried several encoding utf8, latin1,... but nothing has changed. here is my code import pandas as pd df = pd.read_csv("C:/Users/L540/...
user avatar
1vote
1answer
42views

combine rows of single column over multiple .csv files in pandas

I have a bunch of .csv files with the same column headers and data types in the columns. c1 c2 c3 1 5 words 2 6 words 3 7 words 4 8 words is there a way to combine all the ...
user avatar
0votes
1answer
30views

Python - Dictionary list writing to CSV as string, not list - cannot parse into pandas later on

for k,v in groupDict_sanitized.items(): if discovered_hosts_groupid in v: csvdata = (k,v) print(k,v) print(type(v)) #Example from print output #...
user avatar
  • 13
0votes
1answer
45views

Diff two CSVs by specific columns, output matching rows

I am comparing two CSV files. I need to know which rows match by comparing specific columns. The output needs to be the rows that match. Data: CSV 1: name, age, occupation Alice,51,accountant John,23,...
user avatar
0votes
1answer
52views

Compare 2 csv files and check for first 2 columns, if it matches ask the user to decide to override or not and then proceed to next row

I have a use case where I have 2 CSV files with some rows in each CSV file, and they have three columns each. Compare the 2 csv files for first 2 columns and if it matches then ask the user input if ...
user avatar
  • 1
0votes
1answer
49views

how to convert pandas dataframe to binary file in python

import numpy as np import pandas as pd def get_values_for_frequency(freq): # sampling information Fs = 100# sample rate no of samppes per second T = 1/Fs # sampling period %sample per ...
user avatar
  • 57
2votes
2answers
36views

Merging data from a separate .csv file using Pandas

I want to create two new columns in job_transitions_sample.csv and add the wage data from wage_data_sample.csv for both Title 1 and Title 2: job_transitions_sample.csv: Title 1 ...
user avatar
0votes
1answer
31views

How to go onto next available cell in excel using python

So i have the code : user1 = input("What is player 1's first name?") user2 = input("What is player 2's first name?") import csv with open('scores.csv', 'r+', newline='') as ...
user avatar
0votes
1answer
36views

python program to generate a csv file where each column is a data of sinusoidal wave

The requirement is to generate a csv file where each column is a data of sinusoidal wave of frequency 1 Hz,2 Hz, 3Hz, 4Hz, 5Hz, 6Hz, 7Hz. Thus total 7 columns. 100 wave points for 1Hertz and thus ...
user avatar
  • 57
1vote
1answer
81views

Comparing data between two CSV files to move data to a third CSV file

I have this csv file, file1.csv: OU CORP:Jenny Smith: "CORP:John Smith:,John Smith:" STORE:Mary Poppins: STORE:Tony Stark: STORE:Carmen Sandiego: NEWS:Peter Parker: NEWS:Clark Kent: ...
user avatar
1vote
0answers
30views

Is there a better way to add headers to CSV file using Python?

I am trying to add headers to existing csv files using a python script. I found a way to do it but it uses too much of my memory and causes my laptop to crash. I wanted to know if there's a better way ...
user avatar
  • 11
0votes
1answer
23views

How can I exclude/delete specific rows based on time between data entries?

I'm using the following code to parse a log file (from .csv to .csv) so that I will only see entries containing the action "Building Access": with open('output.csv', 'w') as out: for ...
user avatar
  • 19
0votes
1answer
25views

How can I exclude specific rows containing data from text to csv?

Here's what I'm using to parse a log file: import csv import os import numpy def remove_csv_columns(input_csv, output_csv, exclude_column_indices): with open(input_csv) as file_in, open(...
user avatar
  • 19
0votes
1answer
276views

Error: "TypeError: float() argument must be a string or a number, not 'NoneType'", but there is no 'NoneType'?

I am trying to print all the items but there is an error: TypeError: float() argument must be a string or a number, not 'NoneType' I have no clue why it is giving this error. I am using float for ...
user avatar
0votes
1answer
44views

Write Pandas dataframe data to CSV file

I am trying to write a pipeline to bring oracle database table data to aws. It only takes a few ms to fill the dataframe, but when I try to write the dataframe to a csv-file it takes more than 2 min ...
user avatar
-1votes
1answer
28views

CSV read certain range of row

I have 100 rows of data in CSV file Let's say I just want to read rows 56 to 62, is there any way I can just type print(row[1 to 9])?
user avatar
0votes
1answer
39views

Adding images, classes and coordinates of bounding boxes into a csv file

I have an output folder where I have multiple images produced by my inference file. Each image has multiple bounding boxes with class labels (2 categories) and confidence score. In my Inference.py ...
user avatar
0votes
0answers
34views

counting how many times unique value occur in column with reference to other column in .csv using python

I want to calculate for each unique "extId" how many different "Annotation.exact" are occuring, i have attached an image for the reference, i have a file of about 10 million rows ...
user avatar
  • 15
0votes
1answer
22views

Getting KeyError for pandas df column name that exists

I have data_combined = pd.read_csv("/path/to/creole_data/data_combined.csv", sep=";", encoding='cp1252') So, when I try to access these rows: data_combined = data_combined[(...
user avatar
  • 13
0votes
1answer
41views

How can I filter a csv file based on its columns in python?

I have a CSV file with over 5,000,000 rows of data that looks like this (except that it is in Farsi): Contract Code,Contract Type,State,City,Property Type,Region,Usage Type,Area,Percentage,Price,Price ...
user avatar
1vote
1answer
54views

How to deal with "_csv.Error: line contains NULL byte"?

I am trying to fix an issue I'm having with null bytes in a CSV files. The csv_file object is being passed in from a different function in my Flask application: stream = codecs.iterdecode(csv_file....
user avatar
0votes
1answer
42views

How do I convert one column of a csv file to a txt file in Python?

I have a specific column in a csv file and I want to write each row of that column as a newline in the same txt file. I'm using Panda if that helps. I can't quite figure out how to iterate over the ...
user avatar
0votes
1answer
21views

change header of csv python

hi I am writing data on csv using python my code is something like this name_keys =['Record_1', 'Record_2', 'Random_Name'] header_names = ['Record 1', 'Record 2', 'Random Name'] with open(...
user avatar
0votes
1answer
41views

Run multiple times, a script that outputs a `csv`

I have a simulation setup which generates a csv containing the results of the simulation. I want to run this script multiple times and get multiple csv's as a result of each simulation. I tried: ...
user avatar

15 30 50 per page
1
2 3 4 5
84