Skip to main content

All Questions

Tagged with
-2 votes
1 answer
197 views

Write a new CSV File from Existing CSV File with many Conditions

I want to write a CSV File which gets Data from and depending from an existing CSV File. Existing_FILE: Date, Value, Name, sh 2022-01-15, 30,00, Monthly1 - #1500, H 2022-01-18, 130,00, Monthly50, S ...
RichardeRicharde's user avatar
-1 votes
1 answer
110 views

"ValueError: not enough values to unpack (expected 12, got 1)" while creating a list of named tuples

I'm trying to create a list of named tuples from a CSV file. The error pulls up on line 12(the one starting with movie_list). It says that there are not enough values to unpack. I've done multiple ...
victoriaemc's user avatar
2 votes
2 answers
1k views

Why do tuples become strings after saving to csv and reloading the dataframe (pandas)?

import pandas as pd from random import random from collections import namedtuple Smoker = namedtuple("Smoker", ["Female","Male"]) Nonsmoker = namedtuple("...
Paw in Data's user avatar
  • 1,432
0 votes
0 answers
285 views

Writing namedtuple and grouping by name to CSV python

I am trying to write a grouped namedtuple to a CSV, where each line is each name The namedtuple is like this: [FullIndividualResults(Position='48', Cat='B', Name='John Smith ', Team='Team 1', Points='...
PythonIsBae's user avatar
2 votes
1 answer
362 views

Python: How do I store and retrieve dynamic data in a namedtuple to write to a csv? Should I just use object attributes instead?

The goal is to write csv files for each Invoice from a webpage. I'm trying to do this with a webscraper, mainly using selenium Each Invoice has its own number, date, close_date, amount, and list of ...
Glen Cote's user avatar
0 votes
1 answer
45 views

Write all data from once CSV file to another -- but include new parsed geocoding data as additional fields

I'm trying to write a Python script that will take any CSV file, run it through a geocoder, and then write the resulting geocoding attributes (+ all the data from the original file) to a new csv file. ...
Matt BS's user avatar
  • 35
1 vote
2 answers
1k views

Reading Csv into namedtuple

I am trying to load the csv file I got from here: http://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data I have rewritten this dozen of times and now I am getting error saying list ...
Tummomoxie's user avatar
0 votes
1 answer
771 views

List comprehension of namedtuples results in empty list

I've stumbled upon a problem I just can't seem to find an answer for. I am reading the contents of a csv file using csv.DictReader and constructing a list of namedtuples from that information. However,...
Jenez's user avatar
  • 29
1 vote
2 answers
2k views

Looping through a namedtuple

I am a Python noob but not new to programming. I have searched StackOverflow extensively and didn't find the answer (or didn't understand what I have found). This is what I want to do Take info from ...
Hanan Cohen's user avatar
4 votes
4 answers
440 views

Pass list of different named tuples to different csv by tuple name

I have a program in which I wish to record all major changes that occur. For example: each time a variable x changes in value record the time of the change and the change itself. Within the program ...
Pete's user avatar
  • 787
0 votes
2 answers
1k views

choosing right data structure to parse a file

I have a csv file with contents in the following format: CSE110, Mon, 1:00 PM, Fri, 1:00 PM CSE114, Mon, 8:00 AM, Wed, 8:00 AM, Fri, 8:00 AM which is basically course name followed by it's timings. ...
raghu's user avatar
  • 131
1 vote
1 answer
2k views

Python 3 - Read csv file with type conversion

I have two problems: a) Python csv module could not handle particular csv file properly I have the following data in database.csv "AAAAAAAA" , 5.4817, 0.0000, 0.0000, 0.0000, 65....
yoonghm's user avatar
  • 4,517
4 votes
2 answers
1k views

Import Data Into Namedtuple in Python

I am trying to import data into namedtuple. The data is very large and I need to import it efficiently. I am trying myData = namedtuple('myData', 'div, name, val') csv.register_dialect('mycsv', ...
Enes's user avatar
  • 189
1 vote
0 answers
1k views

Optimizing modifiable named list based on namedtuple

My goal is to optimize a framework based on a stack of modifiers for CSV-sourced lists. Each modifier uses a header list to work on a named basis. CSV example (including header): date;place 13/02/...
Benoît's user avatar
  • 16.9k
2 votes
1 answer
2k views

Converting values of named tuples from strings to integers

I'm creating a script to read a csv file into a set of named tuples from their column headers. I will then use these namedtuples to pull out rows of data which meet certain criteria. I've worked out ...
s_boardman's user avatar

15 30 50 per page