I'm relatively new to programming and have started writing some code for work.  This script is something I wrote that I'd like to have someone comment on.  Am I doing anything silly, stupid or totally unnecessary?  Am I making things more complicated than they need to be?This script takes a plain text file downloaded from a publication database (example file below) and processes it to create a csv of the metadata from all the articles and a separate text file for the full text of each article.from sys import argvimport timeimport csvtimestamp = time.strftime('%H%M-%Y%m%d')class Article(object):    fulltxt =     Title =     Publication =     Date =     Year =     Author =     PQID = csvName = 'Metadata_'+timestamp+'.csv'fields = ['ID', 'Title', 'Author', 'Publication', 'Date', 'Year']csvFile = open(csvName, 'wb')csvwriter = csv.DictWriter(csvFile, delimiter=',', fieldnames=fields)#write csv headerscsvwriter.writerow(dict((fn, fn) for fn in fields))def abbreviate(pub):    #a publication abbreviation is included in the filename of the textfile    pubs = {        'USA TODAY (pre-1997 Fulltext)' : 'USAT',        'USA TODAY' : 'USAT',        'New York Times' : 'NYT',        'Wall Street Journal' : 'WSJ'    }    return pubs.get(pub, X)def writeMetadata(doc):    #write the field values of the current doc to the csv file    if doc.fulltxt != :        writefields = dict((field, getattr(doc, field)) for field in vars(doc) if not field.startswith('__') and field != 'fulltxt')        csvwriter.writerow(writefields)def writeArticle(doc):    name = abbreviate(doc.Publication)+'_'+doc.Year+'_'+doc.PQID+'.txt'    txtFile = open(name, 'a')    txtFile.write(doc.Title)    txtFile.write(doc.fulltxt)    txtFile.close()script, filename = argvdocs = open(filename)readingtxt = Falsefor line in docs:    line = line.strip()    if line == '____________________________________________________________':        #write out the previous doc        try: doc        except NameError: doc = None        else:            writeArticle(doc)            writeMetadata(doc)        #start new doc        doc = Article()        continue    if line.startswith(Full text:):         #we're reading the full text         readingtxt = True         doc.fulltxt = line[10:]         continue    elif readingtxt:         if line.startswith(Illustration) or line ==  :            readingtxt = False            continue         else:            doc.fulltxt = doc.fulltxt + \n +line    elif line.startswith(Title:):         doc.Title = line[6:]    elif line.startswith(Publication title:):         doc.Publication = line[19:]    elif line.startswith(Author:):         doc.Author = line[8:]    elif line.startswith(Publication date:):         doc.Date = line[18:]    elif line.startswith(ProQuest document ID:):         doc.PQID = line[22:]    elif line.startswith(Publication year:):         doc.Year = line[18:]    elif not line or line.isspace() :         continue    else:         continuecsvFile.close()docs.close()example text file:____________________________________________________________Report Information from ProQuestAugust 21 2015 10:55________________________________________________________________________________________________________________________Table of contents1. Obama plan: 'Pitiful' or 'compelling'?2. Feeling bullied at school? Call Charlie's angel3. Clinton proposes setting national standards for schools4. A NATION'S HUNGER FOR THE TRUTH Irish confront legacy of the potato famine5. Minnesota's muscle drawing stronger praise Foes intimidated by No. 11 Gophers____________________________________________________________Document 1 of 5Obama plan: 'Pitiful' or 'compelling'?Author: Anonymoushttp://search.proquest.com/docview/862079852?accountid=7379Abstract: The New York Times, in an editorial: (Obama) used his budget speech to clearly distance himself from Republican plans to heap tax benefits on the rich while casting adrift the nation's poor, elderly and unemployed. Karl Rove, former adviser to President Bush, in The Wall Street Journal: The goal Obama laid out -- 'a balanced approach to achieve $4 trillion in deficit reduction over 12 years' -- was missing but one thing: a concrete blueprint. ...Links: http://jy3ke7sv3s.search.serialssolutions.com/?ctx_ver=Z39.88-2004&amp;ctx_enc=info:ofi/enc:UTF-8&amp;rfr_id=info:sid/ProQ%3Anationalnewsexpanded&amp;rft_val_fmt=info:ofi/fmt:kev:mtx:journal&amp;rft.genre=article&amp;rft.jtitle=USA+TODAY&amp;rft.atitle=Obama+plan%3A+%27Pitiful%27+or+%27compelling%27%3F&amp;rft.au=Anonymous&amp;rft.aulast=Anonymous&amp;rft.aufirst=&amp;rft.date=2011-04-15&amp;rft.volume=&amp;rft.issue=&amp;rft.spage=A.9&amp;rft.isbn=&amp;rft.btitle=&amp;rft.title=USA+TODAY&amp;rft.issn=07347456&amp;rft_id=info:doi/Full text: On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsOn the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsOn the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsIllustration PHOTO, B/W, Carolyn Kaster, AP; Caption:Subject: Studies; Tax increases; Fiscal policy; Government spending; Federal budget; EditorialsLocation: United States--USPeople: Obama, BarackTitle: Obama plan: 'Pitiful' or 'compelling'?Publication title: USA TODAYPages: A.9Publication year: 2011Publication date: Apr 15, 2011Year: 2011Section: NEWSPublisher: USA Today, a division of Gannett Satellite Information Network, Inc.Place of publication: McLean, Va.Country of publication: United StatesPublication subject: General Interest Periodicals--United StatesISSN: 07347456Source type: NewspapersLanguage of publication: EnglishDocument type: FeatureProQuest document ID: 862079852Document URL: http://search.proquest.com/docview/862079852?accountid=7379Copyright: (Copyright (c) 2011 USA Today. All Rights Reserved.)Last updated: 2011-05-04Database: National Newspapers Expanded____________________________________________________________Document 2 of 5Feeling bullied at school? Call Charlie's angelAuthor: Parker, Kathleenhttp://search.proquest.com/docview/306803544?accountid=7379Abstract: Some days nothing goes right. I was feeling particularly homicidal recently following a full day of rude encounters with my fellow woman. In one instance, a teen driver dodged in front of me, snatching the last parking space at the grocery store. In another, an elaborately coifed woman leaned on her horn as I waited for oncoming traffic to permit a sane left turn. And in yet another, get this, a woman butted in line in the emergency room (!) where I'd taken by kid for stitches on his split chin. Attorney General Condon's No Bully Line, said an angel's voice with a perfect blend of authority and compassion. I began to tell her about my urgent need to kill mean people when she asked me the name of my school. School? I'm a grown-up, a parent. I don't go to school; I go to grocery stores! Now about these bullies. She stopped me, sweetly. The bully hot line, she explained, was for playground bullies, not horn-blowers and line-butters. Attorney General Charles Charlie Condon, weary of crime statistics, apparently had decided to take the bullies by the horn. Well, why not? when the president of the United States cares (deeply) about women recovering from labor and delivery, why shouldn't an attorney general sift the sandbox?Links: http://JY3KE7SV3S.search.serialssolutions.com/directLink?&amp;atitle=Feeling+bullied+at+school%3F+Call+Charlie%27s+angel&amp;author=Parker%2C+Kathleen&amp;issn=07347456&amp;title=USA+TODAY+%28pre-1997+Fulltext%29&amp;volume=&amp;issue=&amp;date=1997-02-12&amp;spage=11.A&amp;id=doi:&amp;sid=ProQ_ss&amp;genre=articlehttp://JY3KE7SV3S.search.serialssolutions.com/directLink?&amp;atitle=Feeling+bullied+at+school%3F+Call+Charlie%27s+angel&amp;author=Parker%2C+Kathleen&amp;issn=07347456&amp;title=USA+TODAY+%28pre-1997+Fulltext%29&amp;volume=&amp;issue=&amp;date=1997-02-12&amp;spage=11.A&amp;id=doi:&amp;sid=ProQ_ss&amp;genre=articleFull text: Not available.Title: Feeling bullied at school? Call Charlie's angelPublication title: USA TODAY (pre-1997 Fulltext)Pages: 11.ANumber of pages: 0Publication year: 1997Publication date: Feb 12, 1997Year: 1997Section: NEWSPublisher: USA Today, a division of Gannett Satellite Information Network, Inc.Place of publication: McLean, Va.Country of publication: United StatesPublication subject: General Interest Periodicals--United StatesISSN: 07347456Source type: NewspapersLanguage of publication: EnglishDocument type: NEWSPAPERProQuest document ID: 306803544Document URL: http://search.proquest.com/docview/306803544?accountid=7379Copyright: Copyright USA Today Information Network Feb 12, 1997Last updated: 2010-08-27Database: National Newspapers Expanded____________________________________________________________Document 3 of 5Clinton proposes setting national standards for schoolsAuthor: Kelly, Dennishttp://search.proquest.com/docview/306802529?accountid=7379Abstract: The national tests that President Clinton proposed Tuesday night would give states and local school districts a new yardstick to see how their students stack up against the rest of the country and the world. Clinton is proposing that states adopt newly developed, voluntary national tests for fourth-graders in reading and for eighth-graders in math. The tests would be administered begining in 1999. The reading test would be based on the National Assessment of Educational Progress (NAEP), a federal project that has used a random sample of U.S. students to gauge skills in math, reading and other subjects for 27 years.Links: http://jy3ke7sv3s.search.serialssolutions.com/?ctx_ver=Z39.88-2004&amp;ctx_enc=info:ofi/enc:UTF-8&amp;rfr_id=info:sid/ProQ%3Anationalnewsexpanded&amp;rft_val_fmt=info:ofi/fmt:kev:mtx:journal&amp;rft.genre=unknown&amp;rft.jtitle=USA+TODAY+%28pre-1997+Fulltext%29&amp;rft.atitle=Clinton+proposes+setting+national+standards+for+schools%3A+%5BFINAL+Edition%5D&amp;rft.au=Kelly%2C+Dennis&amp;rft.aulast=Kelly&amp;rft.aufirst=Dennis&amp;rft.date=1997-02-05&amp;rft.volume=&amp;rft.issue=&amp;rft.spage=03.A&amp;rft.isbn=&amp;rft.btitle=&amp;rft.title=USA+TODAY+%28pre-1997+Fulltext%29&amp;rft.issn=07347456&amp;rft_id=info:doi/Full text: On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsOn the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsOn the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsOn the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsOn the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsOn the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsIllustrationTitle: Clinton proposes setting national standards for schools:  [FINAL Edition]Publication title: USA TODAY (pre-1997 Fulltext)Pages: 03.ANumber of pages: 0Publication year: 1997Publication date: Feb 5, 1997Year: 1997Section: NEWSPublisher: USA Today, a division of Gannett Satellite Information Network, Inc.Place of publication: McLean, Va.Country of publication: United StatesPublication subject: General Interest Periodicals--United StatesISSN: 07347456Source type: NewspapersLanguage of publication: EnglishDocument type: NEWSPAPERProQuest document ID: 306802529Document URL: http://search.proquest.com/docview/306802529?accountid=7379Copyright: Copyright USA Today Information Network Feb 5, 1997Last updated: 2010-08-20Database: National Newspapers Expanded____________________________________________________________Document 4 of 5A NATION'S HUNGER FOR THE TRUTH Irish confront legacy of the potato famineAuthor: Lynch, David Jhttp://search.proquest.com/docview/306802422?accountid=7379Abstract: LONGFORD, Ireland -- For years, the hilltop cemetery known as Bully's Acre was a debris-strewn ruin. Windswept weeds grew waist high. Dead dogs and empty beer kegs littered the ground. But that was before Sister Calasanctius Duffy came along and before Ireland decided to confront one of the most painful episodes in its long, anguished history: the 1845-1847 famine that killed or forced into exile one-quarter of its 8 million residents. This year, 60,000 people, up one-third from 1996, are expected to visit the Famine Museum in Strokestown, where the tragedy's grim statistics are detailed in words and pictures. Sites like Bully's Acre are being rehabilitated. New research is under way by scholars, with more than 50 books on the famine published since 1994.Links: http://jy3ke7sv3s.search.serialssolutions.com/?ctx_ver=Z39.88-2004&amp;ctx_enc=info:ofi/enc:UTF-8&amp;rfr_id=info:sid/ProQ%3Anationalnewsexpanded&amp;rft_val_fmt=info:ofi/fmt:kev:mtx:journal&amp;rft.genre=unknown&amp;rft.jtitle=USA+TODAY+%28pre-1997+Fulltext%29&amp;rft.atitle=A+NATION%27S+HUNGER+FOR+THE+TRUTH+Irish+confront+legacy+of+the+potato+famine%3A+%5BFINAL+Edition%5D&amp;rft.au=Lynch%2C+David+J&amp;rft.aulast=Lynch&amp;rft.aufirst=David&amp;rft.date=1997-01-15&amp;rft.volume=&amp;rft.issue=&amp;rft.spage=01.D&amp;rft.isbn=&amp;rft.btitle=&amp;rft.title=USA+TODAY+%28pre-1997+Fulltext%29&amp;rft.issn=07347456&amp;rft_id=info:doi/Full text: On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsOn the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsOn the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsOn the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsOn the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsOn the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsOn the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsOn the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsIllustration PHOTOS, Color,Eileen Blass,USA TODAY (3)Title: A NATION'S HUNGER FOR THE TRUTH Irish confront legacy of the potato famine:  [FINAL Edition]Publication title: USA TODAY (pre-1997 Fulltext)Pages: 01.DNumber of pages: 0Publication year: 1997Publication date: Jan 15, 1997Year: 1997Section: LIFEPublisher: USA Today, a division of Gannett Satellite Information Network, Inc.Place of publication: McLean, Va.Country of publication: United StatesPublication subject: General Interest Periodicals--United StatesISSN: 07347456Source type: NewspapersLanguage of publication: EnglishDocument type: COVER STORYProQuest document ID: 306802422Document URL: http://search.proquest.com/docview/306802422?accountid=7379Copyright: Copyright USA Today Information Network Jan 15, 1997Last updated: 2010-07-30Database: National Newspapers Expanded____________________________________________________________Document 5 of 5Minnesota's muscle drawing stronger praise Foes intimidated by No. 11 GophersAuthor: Blauvelt, Harryhttp://search.proquest.com/docview/306790419?accountid=7379Abstract: Make room for brawny Minnesota, the newest bully on the Big Ten basketball block. The No. 11 Golden Gophers (13-1) haven't broken from the starting gate this quickly since 1976-77, when Kevin McHale, Mychal Thompson and Flip Saunders triggered a 16-1 run. In a conference known for its muscle, Minnesota can mix it up with anyone. Center John Thomas, 6-9, 275, a tight end in high school who squats 600 pounds, and power forward Courtney James, 6-8, 275, punish opponents in the paint.Links: http://jy3ke7sv3s.search.serialssolutions.com/?ctx_ver=Z39.88-2004&amp;ctx_enc=info:ofi/enc:UTF-8&amp;rfr_id=info:sid/ProQ%3Anationalnewsexpanded&amp;rft_val_fmt=info:ofi/fmt:kev:mtx:journal&amp;rft.genre=unknown&amp;rft.jtitle=USA+TODAY+%28pre-1997+Fulltext%29&amp;rft.atitle=Minnesota%27s+muscle+drawing+stronger+praise+Foes+intimidated+by+No.+11+Gophers%3A+%5BFINAL+Edition%5D&amp;rft.au=Blauvelt%2C+Harry&amp;rft.aulast=Blauvelt&amp;rft.aufirst=Harry&amp;rft.date=1997-01-08&amp;rft.volume=&amp;rft.issue=&amp;rft.spage=09.C&amp;rft.isbn=&amp;rft.btitle=&amp;rft.title=USA+TODAY+%28pre-1997+Fulltext%29&amp;rft.issn=07347456&amp;rft_id=info:doi/Full text: On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsOn the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsOn the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsOn the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsOn the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsOn the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse painsIllustration PHOTO, B/W, Dale Atkins, APTitle: Minnesota's muscle drawing stronger praise Foes intimidated by No. 11 Gophers:  [FINAL Edition]Publication title: USA TODAY (pre-1997 Fulltext)Pages: 09.CNumber of pages: 0Publication year: 1997Publication date: Jan 8, 1997Year: 1997Section: SPORTSPublisher: USA Today, a division of Gannett Satellite Information Network, Inc.Place of publication: McLean, Va.Country of publication: United StatesPublication subject: General Interest Periodicals--United StatesISSN: 07347456Source type: NewspapersLanguage of publication: EnglishDocument type: NEWSPAPERProQuest document ID: 306790419Document URL: http://search.proquest.com/docview/306790419?accountid=7379Copyright: Copyright USA Today Information Network Jan 8, 1997Last updated: 2010-08-21Database: National Newspapers Expanded____________________________________________________________Contact us at: http://www.proquest.com/go/contactsupportCopyright  2015 ProQuest LLC. All rights reserved.Terms and Conditions: http://search.proquest.com/info/termsAndConditions
Process text file of fulltext articles from news publications
python;beginner;parsing;csv
Constants are CAPITALas a convention, so:TIMESTAMP = time.strftime('%H%M-%Y%m%d')CSV_NAME = 'Metadata_' + timestamp + '.csv' # <- added some spacesFIELDS = ['ID', 'Title', 'Author', 'Publication', 'Date', 'Year']Passing to more serious comments:elif line.startswith(Title:):     doc.Title = line[6:]elif line.startswith(Publication title:):     doc.Publication = line[19:]elif line.startswith(Author:):     doc.Author = line[8:]elif line.startswith(Publication date:):     doc.Date = line[18:]elif line.startswith(ProQuest document ID:):     doc.PQID = line[22:]elif line.startswith(Publication year:):     doc.Year = line[18:]^^ That  was a real puzzler, I know understood that the slicing is there to avoid saving things like ProQuest document ID: or Publication year:, I suggest just using split and [1], like this:elif line.startswith(Publication year:):     doc.Year = line.split(Publication year:)[1]The same result of what you did but more intuitiveIn fact you should use a loop:for salient_part in (Title, Publication Title: ...):    if line.startswith(salient_part):        doc[salient_part] = line.split(salient_part)[1]^ The loop above may need other modifications to your code before working properly (not tested).Possibly, you may stop using the class Article(object):    fulltxt =     Title =     Publication =     Date =     Year =     Author =     ID = And just go for a plain dict, that sure would make the loop simple to implement.Use withtxtFile = open(name, 'a')txtFile.write(Article.Title)txtFile.write(Article.fulltxt)txtFile.close()Should becomewith open(name, 'a') as f:     f.write(Article.Title)     f.write(Article.fulltxt)As it automatically closes the file.Boring == possibly wrongif line == '____________________________________________________________':^^ Counting that the above has the correct number of underscores is boring so I will not do it (which is the correct number anyway?) you should doif line == '_' * NUMBER_OF_UNDERSCORES_NEEDED: