• resserone13

    @ccc i depends on how you wanted to go about it. the teacher mention that some students used csv module. its a really basic class. i used what was explained in class.

    posted in Pythonista read more
  • resserone13

    @JonB your right. i submitted the wrong file types and the files were named incorrectly. ill have to pay more attention to things like that.. the were now working on a dice rolling exerecise and a mystery door game show ... ill make sure to submit the proper file types..

    posted in Pythonista read more
  • resserone13

    this was what i turned in for my homework. my teach said there was some name errors and that the file didnt run completely. maybe he was talking about the type of file i uploaded. it worked fine in my comp. i was using spyder only cus im on my comp. here was the homework and my code

    Create a single Python script (.py) that completes the following steps:

    Read the "US_state_populations.csv" file into Python using any method you like.
    Create a new file called "alphabetic.csv". This file should contain the same 3 columns (state names, 2019 populations, and 2010 populations) separated by commas, but they should sorted alphabetically by the state name. You may write to this file using any method you like. Hint: When you sort the state names, make sure the 2010 and 2019 populations are sorted with their respective states.
    Calculate the change in population between 2010 and 2019 (change = pop2019 - pop2010). Create a new file called "popchange.txt". This file should contain 2 columns: state names and population change, separated by a blank space. The file should contain a header line. You should write to this file manually using a for loop (not numpy, pandas, or any other library).
    Upload your Python script, "alphabetic.csv" and "popchange.txt" to this Canvas assignment.

    list_of_list = []
    #variable with file name.
    file_name = 'C:/Users/resse/Desktop/projects/poptest/US_state_populations2.csv'
    new_file = 'C:/Users/resse/Desktop/projects/poptest/abc2.csv'
    pop_diff = 'C:/Users/resse/Desktop/projects/poptest/pdiff.csv'
    #opens and closes file.
    with open(file_name, 'r') as f:
        #loops over file line by line.
        for line in f:
            #saves each line as a list
            items = line.strip().split(',')
            #adds each list to a list
    #sorts the list
    s = sorted(list_of_list)
    #prints the sorted list
    #opens the new file and adds a sorted list to it.
    with open(new_file, 'w') as n_f:
        for i in s:
            n_f.write(f'\n {i[0]}, {i[1]}, {i[2]}')
    with open(pop_diff, 'w') as d_f:
        #writess the colum headers
        d_f.write(f'p19, p10, pdiff')
        #loops through a sorted list of states and population numbers
        for i in s:
            #calculates the population difference
            diff = int(i[1]) - int(i[2])
            #writes each years population to a colum and 
            #writes the population difference
            d_f.write(f'\n{i[1]}, {i[2]}, {diff}')

    posted in Pythonista read more
  • resserone13

    @JonB thanks for the heads up on the backslashes. i havent worked with file that much and i never noticed.. thanks the isssue was a typo new it too but i had copied and pasted then i typed it. that along with the backslash error it was all mixed up... thanks for all you advice as always.

    posted in Pythonista read more
  • resserone13

    @JonB i got it to find the file with the full path and now in using just the file name... i think i was missing a '' at the beginning of the file name now im getting

    SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-1: truncated \UXXXXXXXX escape

    with this code

    with open('\US_state_populations2.csv', 'r') as f:

    posted in Pythonista read more
  • resserone13

    @cvp im laughing so hard right now. if i turned your code in the teach would be wanting to learn from me(technically you) hahahahah to funny. once i figure out the file not found im going to tryout your code gonna finish mine too. i was gonna get each line and seprate the different parts into a list and pick the items from the list.

    posted in Pythonista read more
  • resserone13

    @cvp im using a windows laptop. here is the code. i need to sort the states and save a new file with the sorted states and populations in colums. it should be easy ive been figuring out most of it and i have the class video as a guide. im trying not to copy the class video. i had it woring but now it stopped.

    cities = []
    pop_2019 = []
    pop_2010 = []
    #opens and closes file 
    with open('US_state_populations.csv', 'r'):
       #iterates over the file. 
       for Line in f:
            #c = f.readline().strip().split(',')
            city = c[0]
            p_2019 = c[1]
            p_2010 = c[2]
    #abc_file = open('alphabetic.csv', 'w',)```

    posted in Pythonista read more
  • resserone13

    long time no see. im trying to do some homework for a cis class im taking at my community college. i need to open a file and its saying file not found. another bull fn ish error that i cant figure out. keeps saying file not found.. i have the .py file in the same folder as the .csv and i have copied and pasted the file name to avoid any misspellings. any suggestions on what else can be the issue..

    posted in Pythonista read more
  • resserone13

    @cvp @ccc @mikael Here is the UI version of the personal protective equipment app. It looks kind of plain. Any suggestions to spruce up how it looks?


    posted in Pythonista read more
  • resserone13

    Thanks @cvp @ccc and @mikael for the help. I was able to get past the hang up and move forward on the app development. I ended up using @ccc suggestion because i was using code very similar to what I already had. I’m finishing up a few more things then I will post on GitHub.

        def add_btn(self, btn_names, actions_list):
            for i, (n, a) in enumerate(zip(btn_names, actions_list)):
                btn= ui.Button()
                btn.font=(btn_fnt, btn_txt_sz)
                btn.frame=(width * 0.15, height * (0.12 + i * 0.1), width * 0.7, height * 0.05)
                btn.corner_radius= btn_corner_radius

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!