473,386 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

I'm having trouble formatting text from a .txt file, into a grid.

Im trying to create a bank statement basically, and Im having trouble formatting the output to a grid, from a .txt file. And I wrote the file, and can read the first line, and want to pull the date out, and seperate the amount. And with the following lines say the date, type of transaction, the location, amount of the transaction, and finally the running total.

here is what I'm looking to achieve with this:(with all the numbers and columns lining up with plenty of space for the characters.)

03/15/11 Beginning Balance 1000.00
03/15/11 Check Hugos 25.00 975.00
03/15/11 Deposit UND 500.00 1475.00


Here is my WORKING code so far
Expand|Select|Wrap|Line Numbers
  1.  
  2. # Writing the file to begin with, I just hard coded it to skip to good stuff#
  3. f = open("acct.txt", 'w')
  4. f.write ("03/15/11, 1000.00\n")
  5. f.write ("03/15/11, C, Hugos, 25.00\n")
  6. f.write ("03/15/11, D, UND, 500.00")
  7. f.close()
  8.  
  9. # first line #
  10. g = open("acct.txt", 'r')
  11. q = g.readline()
  12. for date in q:
  13.     D = q.replace(","," ")
  14.     D = q.replace("\n","") 
  15.  
  16.  
  17.     print D[0:d]
  18. g.close()
any ideas to continue this would be extremely helpful, I am a newby to this, and simpler the better would be awesome!

Thanks guys
Mar 30 '11 #1
1 1465
Mariostg
332 100+
You can improve this. Look at Fancier Output Formatting
Apr 1 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: TomSt | last post by:
Hello, I'm trying to set the ForeColor property on a Menu and and a TreeView using ASP.Net 2.0 and VisualStudio 2005 Beta. This is a VB.Net app Here are the code snippet: ...
2
by: John | last post by:
HI, I'm having trouble importing text files. I had problem with Access '97 that forced me to reinstall. After I did this I couldn't import text files. The Help file recommends reinstall again,...
0
by: Tom | last post by:
I have about 30 labels and textboxes on my web form and the user can input data into the text boxes. Then they click a button and a text file needs to be created. I can create the text file but how...
0
by: sstell | last post by:
I’m doing a Data Transformation Service extract of data under MS-SQL 7.0. I have two fields that are numeric. I need to extract them to a text, fixed length file. When I extract them – I can get...
0
grassh0pp3r
by: grassh0pp3r | last post by:
Hello, I'm trying to make a very simple comments page on my site using PHP and am having problems somewhere. I am very new to PHP. I was able to create one that works with comments appended, but...
13
by: JJ | last post by:
I have a need to input a large tab delimited text file, which I will parse to check it has the expected columns, before allowing the user to submit it to the database. The user may paste the file...
1
by: mbatestblrock | last post by:
so here is my first post http://www.thescripts.com/forum/thread711882.html everything was working just fine for me and I though I had it down, however the way this file is laid out doesnt...
0
by: Bomac8 | last post by:
I have a text file with a four field array like this: DET-01-002737,DET-01-002737,YES,64239764b32fefc915a593f41bdb5730. My program sorts them in the order where the 3rd field says "Yes" or "NO". ...
2
by: Rozzy | last post by:
Hi, I'm having trouble using the proper terminology, so bear with me, I am trying to submit text to a mysql database. I want to be able to allow formatting of this content (like breaking it up into...
1
by: Marty Klunk | last post by:
I have an Access97 data base where we are exporting records out to a text file that is then sent to a customer via EDI transmission. The problem I am having is that during the export process access...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.