Out of range .csv py

Question:

I am trying to extract values from .csv file the problem is i getting an error out of range when using a file with over 6000 data, however when using file with about 200
There is such an error

import csv

# Read the csv file and store the data in a list

data = []

with open('waves_Output_mono.csv', 'r') as csvfile: 

    csvreader = csv.reader(csvfile, delimiter='t') 

    for row in csvreader: 

        data.append(row) 

    

# Extract the x and y values from the data list  

y_values = [float(y[1]) for y in data] 

x_values = [float(x[0]) for x in data]

When i print the data it can print normally

Answers:

Try processing the data with a for so you can print the values:

for value in data:
    print(value)
    x = float(value[0])
    y = float(value[1])
    x_values.append(x)
    y_values.append(y)

This is more code but can help you to identify where is the problem

Answered By: Gonzalo Odiard
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.