Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old April 21st, 2008, 07:57 AM
exoticdisease exoticdisease is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 15 exoticdisease User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 28 m 36 sec
Reputation Power: 0
Database search and sort

Hey all

A few questions regarding a database searching and sorting program that I've been asked to write:

So far I've got this, and I don't think it's very good...it's not close enough to the end goal at any rate:

Code:
# main program starts here!!!
#declare empty lists to hold the names, dates, titles and journals
author=[]
year=[]
title=[]
journal=[]
test=[]

f = open("complete authors.txt", "r", 0)
f.readline()
    
for line in open('complete authors.txt','r').readlines():
    line = f.readline().rstrip('\n').split("\t")
    
    try:
        author.append(line[0])
        year.append(line[1])
        title.append(line[2])
        journal.append(line[3])
    except IndexError:
        print ""

f.close()

#now sort the lists
author.sort()
title.sort()
journal.sort()
year.sort()

# print out our ordered lists 
print "Authors:"
for a in author:
    print a

print "\nYear:"
for d in year:
    print d

print "\nTitle:"
for t in title:
    print t

print "\nJournal:"
for j in journal:
    print j


So that prints out the list of journals authors etc, and sorts them nicely, which is all fine.

I'm short on a few counts:

Firstly, I need to make a user input function so that where the input is as follows:
Search on author (A = ***) or journal (J = ***), where *** is any string [Q = quit]:

Secondly, I need to store the data in list format, as follows:
List of journals (each journal's 'index' is its position in the list)
List of authors (each author's 'index' is its position in the list)
List of papers (each paper's entry is its title, year published, the index of each author(s) and the index of the journal; in this way the name of each journal and author is only stored in one place).

The file is tab delimited and the headings are author, year, title, journal...not very original.

Any help would be much appreciated...I've been told that a good way to do it would be to use a dictionary to define the author against all the other information, but I don't understand how to make a dictionary work for me in this case...

Cheers everyone, sorry for the long message!

Rob

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Database search and sort


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway