Storing a list of arrays into a CSV file and retrieving it back in a different program

0 votes

This is the code that I am using to generate random biases and storing it as a list of array. I have tried reading back the stored CSV file but the format is no longer a list of arrays. Can somebody tell me how I can retrieve back the baizes in the same format? I am not trying to sort the list, i just want to read back the CSV file and retain the original formatting. Thanks in advance!

import csv
import numpy as np

sizes = [784, 30, 10]
biases = [np.random.randn(y, 1) for y in sizes[1:]]
#weights = [np.random.randn(y, x) for x, y in zip(sizes[:-1], sizes[1:])]
biasfile0 = open('C:/Users/Sharath Talikatte/Desktop/Neural 
                              Networks/bias0.csv', 'w', encoding='utf-8')
with biasfile0:
    writerb0 = csv.writer(biasfile0)
    writerb0.writerow(biases[0])

biasfile1 = open('C:/Users/Sharath Talikatte/Desktop/Neural 
                              Networks/bias1.csv', 'w', encoding='utf- 8')
with biasfile1:
    writerb1 = csv.writer(biasfile1)
    writerb1.writerow(biases[1])
Jun 7, 2018 in Python by aryya
• 7,460 points
2,348 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

0 votes
1 answer

How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

answered Apr 17, 2018 in Python by anonymous
3,412 views
0 votes
1 answer

how can i extact all the links from a website using python and save it in a csv file ?

Hi, @Shubham, Web scraping is the technique to ...READ MORE

answered Jun 16, 2020 in Python by Gitika
• 65,890 points
4,059 views
0 votes
1 answer

How to find the value of a row in a csv file in python and print column and row of that value ?

Hello @Khanhh , Use panda to find the value of ...READ MORE

answered Oct 15, 2020 in Python by Niroj
• 82,880 points
6,665 views
0 votes
1 answer

Convert string list of dict from csv into JSON object in python

You can use the ast module Ex: import ast s = """[{'10': ...READ MORE

answered Sep 12, 2018 in Python by Priyaj
• 58,100 points
2,508 views
0 votes
1 answer

Convert string list of dict from csv into JSON object in python

You can use the ast module Ex: import ast s = """[{'10': ...READ MORE

answered Sep 24, 2018 in Python by Priyaj
• 58,100 points
988 views
0 votes
2 answers

In Python, how do I read a file line-by-line into a list?

readline function help to  read line in ...READ MORE

answered Jun 21, 2020 in Python by sahil
• 580 points
1,724 views
0 votes
1 answer

Need a python script to login into a website but username and password are in a txt file (Selenium automation script)

I had a similar requirement. I had ...READ MORE

answered Jan 31, 2019 in Python by Omkar
• 69,230 points
8,234 views
0 votes
1 answer

Is there a way to list out in-built variables and functions of Python?

The in-built variables and functions are defined ...READ MORE

answered May 14, 2019 in Python by Junaid
2,149 views
0 votes
1 answer

How to find the value of a row in a csv file in python?

If you want to find the value ...READ MORE

answered May 20, 2019 in Python by Sanam
19,113 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP