python question. Question 1 require to download the "NovelEnglish_All.txt" file # All Necessary Modules Have Been Imported # Do Not Import Any Additional Modules import json, datetime, csv from pprint import pprint def txt_to_csv(input_file):     """     Question 1     - NovelEnglish_All.txt contains information about English novels.     - Read the NovelEnglish_All.txt with FILE I/O or CSV.     - Use a list of lists to make a CSV file with the appropriate data WITHOUT WHITESPACE (remove \n) named "novels.csv".     - Ensure you using the correct delimiter for each line ("\t")     - Exclude the "Corpus" column, and strip the quotes from the "Author" column.     - Return the list of lists.     Args:         input_file (NovelEnglish_All.txt)     Returns:         List of lists     Output:     [['id', 'Year', 'Author', 'Title'],     ['1', '2001', 'Martel,Yann', 'LifeofPi'],     ['2', '2002', 'Kidd,SueMonk', 'TheSecretLifeofBees'],     ['3', '2002', 'Sebold,Alice', 'LovelyBones'],     ['4', '2003', 'Hosseini,Khaled', 'TheKiteRunner'],     ...     ['1210', '2015', 'William,EliKP', 'CashCrashJubilee'],     ['1211', '2015', 'Womack,Gwendolyn', 'TheMemoryPainter']] pprint(txt_to_csv("NovelEnglish_All.txt"))

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

python question. Question 1 require to download the "NovelEnglish_All.txt" file

# All Necessary Modules Have Been Imported
# Do Not Import Any Additional Modules

import json, datetime, csv
from pprint import pprint

def txt_to_csv(input_file):
    """
    Question 1
    - NovelEnglish_All.txt contains information about English novels.
    - Read the NovelEnglish_All.txt with FILE I/O or CSV.
    - Use a list of lists to make a CSV file with the appropriate data WITHOUT WHITESPACE (remove \n) named "novels.csv".
    - Ensure you using the correct delimiter for each line ("\t")
    - Exclude the "Corpus" column, and strip the quotes from the "Author" column.
    - Return the list of lists.

    Args:
        input_file (NovelEnglish_All.txt)
    Returns:
        List of lists

    Output:
    [['id', 'Year', 'Author', 'Title'],
    ['1', '2001', 'Martel,Yann', 'LifeofPi'],
    ['2', '2002', 'Kidd,SueMonk', 'TheSecretLifeofBees'],
    ['3', '2002', 'Sebold,Alice', 'LovelyBones'],
    ['4', '2003', 'Hosseini,Khaled', 'TheKiteRunner'],
    ...
    ['1210', '2015', 'William,EliKP', 'CashCrashJubilee'],
    ['1211', '2015', 'Womack,Gwendolyn', 'TheMemoryPainter']]

pprint(txt_to_csv("NovelEnglish_All.txt"))

id
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Title Corpus
37
38
39
40
41
42
43
Year Author
2001 "Martel, Yann"
2002 "Kidd, SueMonk"
2002 "Sebold, Alice"
LifeofPi
BS
The SecretLifeofBees
LovelyBones BS
2007 "Diaz, Junot"
2007 "Follett, Ken"
2007 "Hosseini, Khaled"
2007 "Larsson, Stieg"
2007 "Young, WilliamP.
2008 "Akpan, Uwem"
2008 "Beck, Glenn"
2008 "Benioff, David"
2008 "Cleave, Chris"
2003 "Hosseini, Khaled" TheKiteRunner
2004 "Mitchell, David" CloudAtlas BS
2004
"Picoult, Jodi"
2005 "Connelly, Michael"
2005 "Gardner, Lisa"
2005 "Giffin, Emily"
2005 "Larsson, Stieg"
2005 "SafranFoer, Jonathan"
2006 "Brooks, Max"
2006 "Gruen, Sara"
2006 "Jacobs, Kate"
2006 "Larsson, Stieg"
2006 "Sparks, Nicholas" Dear John BS
2007 "deRosnay, Tatiana"
MySistersKeeper BS
Alone BS
TheLincoln Lawyer BS
SomethingBorrowedBS
TheGirlWithThe DragonTattoo BS
WorldWarZ
ExtremelyLoudandIncrediblyClose BS
BS
WaterforElephants BS
Friday NightKnitting
The Girl Who PlayedWithFire
"Cornwell, Patricia"
2008
2008 "Grisham, John"
TheAppeal BS
2008 "Hannah, Kristin" FireflyLane BS
"Hilderbrand, Elin"
2008
2008
"Meyer, Stephanie" TheHost
2008 "Patterson, James" Cross Country
2008
34
2008
35
2008
36 2008
BS
SarahsKey BS
WorldWithoutEnd BS
AThousandSplendidBS
TheBriefWondrousLifeofOscarWao
BS
Scarpetta BS
Barefoot
The Girl WhoKickedThe Hornet'sNest BS
"TheShack
BS
Say YoureOne BS
Christmas Sweater BS
Cityof Thieves
LittleBee
BS
BS
BS
"Sparks, Nicholas" TheLuckyOne BS
AmericanWife
2008 "Stein, Garth"
2008 "Strout, Elizabeth"
2008
"Wroblewski, David"
2009 "Blake, Sarah"
2009 "Brown, Dan" TheLostSymbol
2009 "Conroy, Pat"
SouthofBroad
2009 "Goolrick, Robert" AReliableWife
BS
BS
"Patterson, James" SundaysatTiffanys BS
"Shaffer, MaryAnn" TheGuernseyLiteraryandPotatoPeelPie
"Sittenfeld, Curtis"
Postmistress
BS
BS
TheArtofRacingintheRain
OliveKItteridge BS
BS
BS
BS
BS
TheStoryofEdgarSawtelle
BS
BS
BS
BS
BS
Transcribed Image Text:id 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 Title Corpus 37 38 39 40 41 42 43 Year Author 2001 "Martel, Yann" 2002 "Kidd, SueMonk" 2002 "Sebold, Alice" LifeofPi BS The SecretLifeofBees LovelyBones BS 2007 "Diaz, Junot" 2007 "Follett, Ken" 2007 "Hosseini, Khaled" 2007 "Larsson, Stieg" 2007 "Young, WilliamP. 2008 "Akpan, Uwem" 2008 "Beck, Glenn" 2008 "Benioff, David" 2008 "Cleave, Chris" 2003 "Hosseini, Khaled" TheKiteRunner 2004 "Mitchell, David" CloudAtlas BS 2004 "Picoult, Jodi" 2005 "Connelly, Michael" 2005 "Gardner, Lisa" 2005 "Giffin, Emily" 2005 "Larsson, Stieg" 2005 "SafranFoer, Jonathan" 2006 "Brooks, Max" 2006 "Gruen, Sara" 2006 "Jacobs, Kate" 2006 "Larsson, Stieg" 2006 "Sparks, Nicholas" Dear John BS 2007 "deRosnay, Tatiana" MySistersKeeper BS Alone BS TheLincoln Lawyer BS SomethingBorrowedBS TheGirlWithThe DragonTattoo BS WorldWarZ ExtremelyLoudandIncrediblyClose BS BS WaterforElephants BS Friday NightKnitting The Girl Who PlayedWithFire "Cornwell, Patricia" 2008 2008 "Grisham, John" TheAppeal BS 2008 "Hannah, Kristin" FireflyLane BS "Hilderbrand, Elin" 2008 2008 "Meyer, Stephanie" TheHost 2008 "Patterson, James" Cross Country 2008 34 2008 35 2008 36 2008 BS SarahsKey BS WorldWithoutEnd BS AThousandSplendidBS TheBriefWondrousLifeofOscarWao BS Scarpetta BS Barefoot The Girl WhoKickedThe Hornet'sNest BS "TheShack BS Say YoureOne BS Christmas Sweater BS Cityof Thieves LittleBee BS BS BS "Sparks, Nicholas" TheLuckyOne BS AmericanWife 2008 "Stein, Garth" 2008 "Strout, Elizabeth" 2008 "Wroblewski, David" 2009 "Blake, Sarah" 2009 "Brown, Dan" TheLostSymbol 2009 "Conroy, Pat" SouthofBroad 2009 "Goolrick, Robert" AReliableWife BS BS "Patterson, James" SundaysatTiffanys BS "Shaffer, MaryAnn" TheGuernseyLiteraryandPotatoPeelPie "Sittenfeld, Curtis" Postmistress BS BS TheArtofRacingintheRain OliveKItteridge BS BS BS BS BS TheStoryofEdgarSawtelle BS BS BS BS BS
Expert Solution
Step 1

As per the given question, we need to implement a function named txt_to_csv that converts text file to CSV file.

Inside the function, read the NovelEnglish_All.txt with FILE I/O or CSV.

Use a list of lists to make a CSV file with the appropriate data WITHOUT WHITESPACE (remove \n) named "novels.csv".

Ensure using the correct delimiter for each line ("\t")

Exclude the "Corpus" column, and strip the quotes from the "Author" column.

Return the list of lists.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education