[Python] Concatenate a List containing numbers and write it to an output file.

There was something like pickle, but it seems to be a bug if there are numbers in it, so I will do it primitively.

data = [[1,2,3,4,5,6], [1,2,3,4,5,6]]

def c(data):
    outputfile = open("./output.txt", "w")
    for d in data:
        if(len(d) == 6):
            str_list = map(str, d)
            write_data = ",".join(str_list)+"\n"





Point --Don't forget to close the file you used once --Convert all elements to String with map

Recommended Posts

[Python] Concatenate a List containing numbers and write it to an output file.
Write standard output to a file
[Python] How to output a pandas table to an excel file
Recursively get the Excel list in a specific folder with python and write it to Excel.
[Python] How to scrape a local html file and output it as CSV using Beautiful Soup
[Python scraping] Output the URL and title of the site containing a specific keyword to a text file
[Python] Create a linebot to write a name and age on an image
Output python log to both console and file
Let's write a Python program and run it
I want to write to a file with Python
Divide each PowerPoint slide into a JPG file and output it with python
How to write a list / dictionary type of Python3
Read json file with Python, format it, and output json
Output a binary dump in binary and revert to a binary file
Created a Python library to write complex comprehensions and reduce in an easy-to-read manner
It would be wise to write like boolean and "A" or "B" [Python] [But]
Read and write a file
Write and read a file
Change the standard output destination to a file in Python
How to write a metaclass that supports both python2 and python3
A python beginner tried to intern at an IT company
An easy way to view the time taken in Python and a smarter way to improve it
How to write a Python class
[Python] Write to csv file with Python
Output to csv file with Python
Output the key list included in S3 Bucket to a file
Make it possible to output a log to a file with go echo
Process Splunk execution results using Python and save to a file
Started Python: Swap an array of values obtained from SQL results to a list type and use it in IN of another query
Python --Get bitcoin rate BTC / JPY from bitflyer at regular intervals and save it to a file
[Introduction to Python] What is the difference between a list and a tuple?
How to convert Python to an exe file
Output the report as PDF from DB with Python and automatically attach it to an email and send it
Write a C language linked list in an object-oriented style (with code comparison between Python and Java)
Tips: [Python] Randomly restore and extract an array from a fasta file
Write O_SYNC file in C and Python
How to put a half-width space before letters and numbers in Python.
A python program that resizes a video and turns it into an image
String conversion of a list containing numbers
Tips for Python beginners to use Scikit-image examples for themselves 3 Write to a file
Python> Output numbers from 1 to 100, 501 to 600> For csv
Read CSV file with Python and convert it to DataFrame as it is
Get the list in the S3 bucket with Python and search with a specific Key. Output the Key name, last update date, and count number to a file.
Compress python data and write to sqlite
How to input a character string in Python and output it as it is or in the opposite direction.
I want to pass an argument to a python function and execute it from PHP on a web server
Use BeautifulSoup to extract a link containing a string from an HTML file
How to save the feature point information of an image in a file and use it for matching
A python beginner tried to intern at an IT company [Day 1 development process]
Reinforcement learning 35 python Local development, paste a link to myModule and import it.
[Introduction to Pandas] Read a csv file without a column name and give it a column name
[Python] How to name table data and output it in csv (to_csv method)
Attempt to launch another .exe and save the console output to a text file
Use libsixel to output Sixel in Python and output a Matplotlib graph to the terminal.
Fourier transform the wav file read by Python, reverse transform it, and write it again.
Output timing is incorrect when standard (error) output is converted to a file in Python
A complete guidebook to using pyenv, pip and python in an offline environment
How to read a serial number file in a loop, process it, and graph it
Searching for an efficient way to write a Dockerfile in Python with poetry
[Python] List Comprehension Various ways to create a list
How to read a CSV file with Python 2/3