Python Forum
Array - Problem with Simple Code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Array - Problem with Simple Code
#8
Ok-Got it!.
So the result (output) is now considered an array? The output 'Array' looks the same as the list output.
    data_list = []
    with open("student_advisees_testdata.csv",'r') as csv_file:
        csv_reader = csv.reader(csv_file)
        next(csv_reader)
        for line in csv_file:
            line = line.split(',')
            data_list.append(line)
    print(data_list)
   
        
#    student = Array(len(data_list))
#    index = 0
#    for index in range(len(data_list)):
#        student[index] = data_list[index]
#    print(student)
    
    student = Array(len(data_list))
    for index, item in enumerate(data_list):
        student[index] = item 
    print(student)
data_list:
[['104', 'Todd', 'Jeffries', 'B25590S', '1/11/16', 'Williams', '2017SU', '3.9\n'], ['47', 'Morty', 'Evans', 'B25590C', '8/21/17', 'Williams', '2017FA', '3.1\n'], ['257', 'Jennifer', 'Reynolds', 'B25590N', '1/17/17', 'Williams', '2017FA', '2.9\n'], ['1707', 'Twan', 'Jelens', 'B25590C', '8/15/16', 'Williams', '2017SP', '3.3\n'], ['1865', 'Paul', 'Knapp', 'B25590S', '8/15/16', 'Williams', '2018FA', '3.4\n'], ['2104', 'Michelle', 'Cashwell', 'B25590C', '8/15/16', 'Smith', '2017SP', '3.25\n'], ['2214', 'Bruce', 'Ciani', 'B25590N', '8/15/16', 'Williams', '2017SP', '2.9\n'], ['2215', 'Mike', 'Carmella', 'B25590C', '8/15/16', 'Williams', '2018SP', '3.8\n'], ['2838', 'Gene', 'Balzano', 'B25590C', '5/30/17', 'Williams', '2018FA', '2.7\n'], ['3104', 'Steve', 'Abrams', 'B25590S', '8/21/17', 'Williams', '2018FA', '3.15']]
student(Array?)
[['104', 'Todd', 'Jeffries', 'B25590S', '1/11/16', 'Williams', '2017SU', '3.9\n'], ['47', 'Morty', 'Evans', 'B25590C', '8/21/17', 'Williams', '2017FA', '3.1\n'], ['257', 'Jennifer', 'Reynolds', 'B25590N', '1/17/17', 'Williams', '2017FA', '2.9\n'], ['1707', 'Twan', 'Jelens', 'B25590C', '8/15/16', 'Williams', '2017SP', '3.3\n'], ['1865', 'Paul', 'Knapp', 'B25590S', '8/15/16', 'Williams', '2018FA', '3.4\n'], ['2104', 'Michelle', 'Cashwell', 'B25590C', '8/15/16', 'Smith', '2017SP', '3.25\n'], ['2214', 'Bruce', 'Ciani', 'B25590N', '8/15/16', 'Williams', '2017SP', '2.9\n'], ['2215', 'Mike', 'Carmella', 'B25590C', '8/15/16', 'Williams', '2018SP', '3.8\n'], ['2838', 'Gene', 'Balzano', 'B25590C', '5/30/17', 'Williams', '2018FA', '2.7\n'], ['3104', 'Steve', 'Abrams', 'B25590S', '8/21/17', 'Williams', '2018FA', '3.15']]
Reply


Messages In This Thread
Array - Problem with Simple Code - by emerger - Oct-11-2018, 03:02 AM
RE: Array - Problem with Simple Code - by stullis - Oct-11-2018, 03:38 AM
RE: Array - Problem with Simple Code - by emerger - Oct-11-2018, 03:52 AM
RE: Array - Problem with Simple Code - by volcano63 - Oct-11-2018, 10:16 AM
RE: Array - Problem with Simple Code - by emerger - Oct-11-2018, 09:00 PM
Arrays - Populating an Array - by emerger - Oct-11-2018, 07:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Simple code not working properly tmv 2 484 Feb-28-2025, 09:27 PM
Last Post: deanhystad
  python code to calculate mean of an array of numbers using numpy viren 3 1,174 May-29-2024, 04:49 PM
Last Post: Gribouillis
  Help with simple code JacobSkinner 1 1,316 Mar-18-2024, 08:08 PM
Last Post: deanhystad
  I have a code which is very simple but still I cannot detect what's wrong with it max22 1 1,241 Nov-07-2023, 04:32 PM
Last Post: snippsat
  A simple problem, how best to solve it? SuchUmami 2 1,365 Sep-01-2023, 05:36 AM
Last Post: Pedroski55
  help me simple code result min and max number abrahimusmaximus 2 1,673 Nov-12-2022, 07:52 AM
Last Post: buran
  Simple encoding code ebolisa 3 2,291 Jun-18-2022, 10:59 AM
Last Post: deanhystad
  How to solve this simple problem? Check if cvs first element is the same in each row? thesquid 2 1,936 Jun-14-2022, 08:35 PM
Last Post: thesquid
  How would you (as an python expert) make this code more efficient/simple coder_sw99 3 2,566 Feb-21-2022, 10:52 AM
Last Post: Gribouillis
  Simple code question about lambda and tuples JasPyt 7 4,763 Oct-04-2021, 05:18 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020