Question

PYTHON PROGRAMMING LANGUAGE Task 5 Open a csv file for writing create 3 rows that store...

PYTHON PROGRAMMING LANGUAGE


Task 5
Open a csv file for writing

create 3 rows that store username, first name, last name and age data (four columns)

write the data to the csv file under the correct column



Task 6

Open the file in task 5) and read its contents

Output the content in a tabular format of columns and values
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Task 5

 import csv data_list = [["username", "first_name", "last_name", "age"], ["username1", "firstname1", "lastname1", 23], ["username2", "firstname2", "lastname2", 31], ["username3", "firstname2", "lastname3", 28],] with open('csv_filename.csv', 'w', newline='') as file: writer = csv.writer(file) writer.writerows(data_list)

Task 6

 import csv with open('csv_filename.csv', 'r') as file: reader = csv.reader(file) for row in reader: print(row)

Hope it will help

Please hit the upvote button

Thank you.

Add a comment
Know the answer?
Add Answer to:
PYTHON PROGRAMMING LANGUAGE Task 5 Open a csv file for writing create 3 rows that store...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Any Language write a function to loop through a csv file (10 rows no headers)...

    In Any Language write a function to loop through a csv file (10 rows no headers) and pull out the data from the 3rd column (string). Create one string with those values separated by commas in arranged in alphabetical order by the first letter (example: “Amazon, Aaron, Base, …..”, Amazon and Aaron do not need to be reversed). It can be assumed the csv file is already read into a variable. Please provide comments.

  • Using C# or Python, write a code that reads a Microsoft Excel CSV file named "LabAssignment"...

    Using C# or Python, write a code that reads a Microsoft Excel CSV file named "LabAssignment" then outputs all the collected and formated data as another Microsoft Excel CSV file named "labOutput" The CSV file contains 25 colums as well close to 200 rows of data. Write a code in C# or Python so that: It removes all unwanted columns along with its data...the columns that should be kept have the following header: "User" "Location" "Feature" "HoursUsed" Remove all files...

  • According to Wikipedia , a comma-separated values (CSV) file is a delimited text file that uses...

    According to Wikipedia , a comma-separated values (CSV) file is a delimited text file that uses a comma to separate values. A CSV file stores tabular data (numbers and text) in plain text. Each line of the file is a data record. Each record consists of one or more fields, separated by commas. The use of the comma as a field separator is the source of the name for this file format. A company has text data that is not...

  • Python Assignment In this assignment, you will use Pandas library to perform analysis on the dataset stored in the following csv file: breast-cancer-wisconsin.csv. Please write script(s) to do the fol...

    Python Assignment In this assignment, you will use Pandas library to perform analysis on the dataset stored in the following csv file: breast-cancer-wisconsin.csv. Please write script(s) to do the following: 1. Read the csv file and covert the dataset into a DataFrame object. 2. Persist the dataset into a SQL table and a JASON file. • Write the content of the DataFrame object into an SQLite database table. This will convert the dataset into a SQL table format. You can...

  • Write a class named SatData that reads a JSON file containing data on 2010 SAT results...

    Write a class named SatData that reads a JSON file containing data on 2010 SAT results for New York City and writes the data to a text file in CSV (comma-separated values) format. It just needs to read a local JSON file - it doesn't need to access the internet. Specifically, your class should have an init method that reads the file, and it should have a method named save_as_csv that takes as a parameter a list of DBNs (district...

  • programming language is C++. Please also provide an explanation of how to create a file with...

    programming language is C++. Please also provide an explanation of how to create a file with the given information and how to use that file in the program Let's consider a file with the following student information: John Smith 99.0 Sarah Johnson 85.0 Jim Robinson 70.0 Mary Anderson 100.0 Michael Jackson 92.0 Each line in the file contains the first name, last name, and test score of a student. Write a program that prompts the user for the file name...

  • Create a program (Lab9_Act1_Write.py) that will read in data from the keyboard and store it in...

    Create a program (Lab9_Act1_Write.py) that will read in data from the keyboard and store it in a file. Your program should prompt the user for the name of the file to use and then request values be entered until the user is done. This data should be written to two files: a text file, user_file_name.txt and a comma separated value file, user_file_name.csv. To help you with decision making, we suggest that you ask the user to input data representing students’...

  • PLEASE DO IT IN PYTHON, THANK YOU! CSV file: This is a file containing plain text...

    PLEASE DO IT IN PYTHON, THANK YOU! CSV file: This is a file containing plain text where each line in the file represents one record of information, and each piece of info in the record is separated by a single comma. Luckily the values won't ever contain commas themselves for this project. But they might start or end with non visible characters (e.g. space, tab). Thus, you must remove the leading and trailing spaces when you store the data in...

  • I am trying to create a function to read 2 csv files that contain 5 columns...

    I am trying to create a function to read 2 csv files that contain 5 columns of data. Columns 1-4 are floats and column 5 is a string. I want to only work on with the floats to perform some calculations such as sum of the first 2 columns of each file and then return the closest numbers then return the string to identify the 2 rows of data. Below is what I have so far. There is a stipulation...

  • Please use python Programming Language: Select one of the following topics: Band Character Account Create a...

    Please use python Programming Language: Select one of the following topics: Band Character Account Create a class based on your chosen topic. Make sure to include at least four attributes of varying types, a constructor, getters/setters for each attribute w/input validation, a toString, a static attribute, and a static method. Then, create a function (outside of your class) that connects to a text file which should contain the attributes of several objects. Read the data from the file, use the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT