Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am not allowed any type of imports to do this question, so i am am very confused on how i can achieve the desired

I am not allowed any type of imports to do this question, so i am am very confused on how i can achieve the desired output.

The desired output: (they are just showing a part of the output,my focus is to have 5 lines as the output )

Argentina,ARG,Feb 18 2020,0 Argentina,ARG,Feb 19 2020,0 Argentina,ARG,Feb 20 2020,0 

The current output i have (was required to produce this):

Argentina,ARG,"Feb 18, 2020",0 Feb 18 2020 Argentina,ARG,"Feb 19, 2020",0 Feb 19 2020 Argentina,ARG,"Feb 20, 2020",0 Feb 20 2020 Argentina,ARG,"Feb 21, 2020",0 Feb 21 2020 Argentina,ARG,"Feb 22, 2020",0 Feb 22 2020 

Some lines from the original CSV file:

Entity,Code,Date,Daily tests per thousand people (7-day smoothed) (tests per thousand) Argentina,ARG,"Feb 18, 2020",0 Argentina,ARG,"Feb 19, 2020",0 Argentina,ARG,"Feb 20, 2020",0 Argentina,ARG,"Feb 21, 2020",0 Argentina,ARG,"Feb 22, 2020",0 Argentina,ARG,"Feb 23, 2020",0 Argentina,ARG,"Feb 24, 2020",0 Argentina,ARG,"Feb 25, 2020",0 Argentina,ARG,"Feb 26, 2020",0 Argentina,ARG,"Feb 27, 2020",0 Argentina,ARG,"Feb 28, 2020",0 Argentina,ARG,"Feb 29, 2020",0 Argentina,ARG,"Mar 1, 2020",0 Argentina,ARG,"Mar 2, 2020",0 Argentina,ARG,"Mar 3, 2020",0 

My current code for my current output:

N=5 with open(DATA)as file: next(file) for i in range(N): line = next(file).strip().split(",") print(",".join(line)) print(line[2].replace('"',''),line[3].replace('"','')) 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions