Trying save the output of a randomly generated list of integers into my personal onedrive. The CSV file ins't saving

56 Views Asked by At

Here's my code. I am looking for a "group1" csv file to be created and stored in the path. As you can see, the code generates and prints random numbers that fit the shape and sample size I want but not giving me a file. Help

import numpy as np
import csv

# Group 1
# Generate a list of 90 integers that have a mean of 140, standard deviation of 10, and are normally distributed
np.random.seed(42)
mean = 140
sd = 10
Size = 90
list_of_90_integers = np.random.normal(mean, sd, size=90).astype(int)
#2. creat a CSV file from the list as 'group1CSV'
with open('group1CSV', 'w', newline = '') as file:
   writer = csv.writer(file)
   writer.writerow(group1)

#3. Define working path 
path = r'C:\Users\Home\OneDrive\Documents\Data Science\Synthetic Data Files'
#4.Save the CSV file to path
with open(path + 'group1CSV', 'w', newline = '') as file:
   writer = csv.writer(file)
   writer.writerow(group1)
   print(group1)
0

There are 0 best solutions below