About 724,000 results
Open links in new tab
  1. How to read CSV file in Python? - Stack Overflow

    May 15, 2016 · def read_csv(csv_file): data = [] with open(csv_file, 'r') as f: # create a list of rows in the CSV file rows = f.readlines() # strip white-space and newlines rows = list(map(lambda x:x.strip(), rows)) for row in rows: # further split each row into columns assuming delimiter is comma row = row.split(',') # append to data-frame our new row ...

  2. Why does my Python code print the extra characters "" when …

    Dec 21, 2015 · Note that if you're on Python 2, you should see e.g. Python, Encoding output to UTF-8 and Convert UTF-8 with BOM to UTF-8 with no BOM in Python. You'll need to do some shenanigans with codecs or with str.decode for this to work right in Python 2. But in Python 3, all you need to do is set the encoding= parameter when you open the file.

  3. python - How do I read and write CSV files? - Stack Overflow

    Essentially we have a object type which we will put the data into, each user's data will go into one object containing 'name, age, startdate'. then we will populate each object and store them to a list in the order they were read from the file. import csv # We need a default object for each person class Person: def __init__(self, Name, Age ...

  4. python - Import CSV file as a Pandas DataFrame - Stack Overflow

    To read a CSV file as a pandas DataFrame, you'll need to use pd.read_csv, which has sep=',' as the default.. But this isn't where the story ends; data exists in many different formats and is stored in different ways so you will often need to pass additional parameters to read_csv to ensure your data is read in properly.

  5. Azure Blob - Read using Python - Stack Overflow

    I need to read a file from blob as a stream, do some processing and write it back to the blob. The whole Python app will run as a webjob. I know i can download the file from blob to Webjob console (D:) but wanted to know if there is a similar functionality of .Net in Python without having to download the file in drive. –

  6. python - How to import a csv-file into a data array ... - Stack …

    Oct 7, 2017 · You can use pandas library or numpy to read the CSV file. If your file is tab-separated then use '\t' in place of comma in both sep and delimiter arguments below. import pandas as pd myFile = pd.read_csv('filepath', sep=',') Or . import numpy as np myFile = np.genfromtxt('filepath', delimiter=',')

  7. Importing csv from a subdirectory in Python - Stack Overflow

    Apr 19, 2012 · Another common trap with windows paths is that using backslashes escape characters, so you must escape your backslashes ("some\\file") - an ugly option, use raw strings (r"some\file"), use forward slashes (Python will actually handle this automatically), or - the best option, pass your path as arguments to the aforementioned os.path.join().

  8. How to read one single line of csv data in Python?

    @MahsanNourani The file pointer can be moved to anywhere in the file, file.seek(0) will move it back to the start for example and then you can re-read from start. You'll have to keep the file open obviously to perform seek operation.

  9. How to read a csv file from an s3 bucket using Pandas in Python

    Jun 13, 2015 · def read_file(bucket_name,region, remote_file_name, aws_access_key_id, aws_secret_access_key): # reads a csv from AWS # first you stablish connection with your passwords and region id conn = boto.s3.connect_to_region( region, aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key) …

  10. python - Pandas read_csv can't find file - Stack Overflow

    Jun 14, 2020 · Pandas.read_csv, Python can also look in a specified folder “current working directory“ I have to do by directory path most of the time myself and set my encoding and add a r before also. data = pd.read_csv(r'C:\Users\path\to\your\file\mess.csv', encoding='utf8') data.head() you can also rename the file name to keep it simple. 1.01.

Refresh