Computing.Net > Forums > Programming > complicated file creation in Python

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

complicated file creation in Python

Reply to Message Icon

Name: jbmellophone
Date: June 8, 2009 at 15:12:09 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

Hello!

I have a lot of files that I need to process in the same way, so I think that's batch processing? Sorry, I'm new at this! The section of each file that I want is in the middle, between two lines of text and symbols that I don't want. I don't want to delete the original file, I just want to append the filename by deleting the ".txt" part and adding 'convo." The files that I want to convert are each in folders, and all are .txt files. I'd like to be able to copy the program into each folder, run it once, and have all the files in the folder copied and the formatted as described above. It's a list of data that is both tab and comma delimited, so I've added a part on the end where it deletes the commas, degree symbols, and the strings that surround the data. Can anyone help me get this to work? Here's the program I have so far(I have bits and pieces from various sources):

import os
import sys
import fileinput
import copy

print "Text to search for:"
textToSearchFor = raw_input( "Format: [Time/Date , Temperature] (Celsius) " )

#print "Text to replace it with:"
#textToReplaceWith = raw_input( "> " )

print "File to perfrom search-and-replace on:"
fileToSearch  = raw_input( "*.txt " )

#name new file
oldFileName  = fileToSearch
tempFileName = fileToSearch + 'convo'

# If there's already an 'old_' prefixed backup file there from
# a previous run, remove it...
#if os.path.isfile( oldFileName ):
#       os.remove( oldFileName )

tempFile = open( tempFileName, 'w' )

for line in fileinput.input( fileToSearch ):
        NewText = copy ('Format\: [Time\/Date , Temperature] (Celsius) ... Debug Dump')
        tempFile.write( line.write( NewText ) )
        delete ('Format: [Time/Date , Temperature] (Celsius)')
        delete ('Debug Dump')
        delete (',')
        delete ('°C')

tempFile.close()

# Rename the original file by prefixing it with 'old_'
#os.rename( fileToSearch, oldFileName )

# Rename the temporary file to what the original was named...
os.rename( tempFileName, fileToSearch - '.txt' + 'convo' )

raw_input( '\n\nPress Enter to exit...' )

And this is what the data should look like in the end:
6/15/2005 5:59 21.5
6/15/2005 6:04 21.5
6/15/2005 6:09 21.5
6/15/2005 6:14 21.5
6/15/2005 6:19 22
6/15/2005 6:24 22.5
6/15/2005 6:29 23
6/15/2005 6:34 22.5
6/15/2005 6:39 22.5

There are anywhere from 500-2048 lines of data that I'm trying to extract.

Hope someone can help, thanks!

Jenny :-)



Sponsored Link
Ads by Google

Response Number 1
Name: ghostdog
Date: June 8, 2009 at 16:45:52 Pacific
Reply:

if you are new to Python, why don't you start from the beginning? read the documentation on how to use Python. you cut and paste code from elsewhere but then don't know what it does.


0

Response Number 2
Name: jbmellophone
Date: June 9, 2009 at 08:24:45 Pacific
Reply:

I've worked with Python before, but not with this type of commands, my previous stuff was with mathematical modeling. Can you at least get me started in the right direction and let me know what I'm doing wrong? I need to have these files finished soon, so I can't really read ALL of the documentation. Can you tell me what sections are important for what I'm trying to do?


0

Response Number 3
Name: ghostdog
Date: June 9, 2009 at 08:33:50 Pacific
Reply:

then, you should post example of your input file. also post your expected output file. i will show you how its normally done.


0

Response Number 4
Name: jbmellophone
Date: June 9, 2009 at 09:18:52 Pacific
Reply:

ok, here's the input file(2005BB1C1_A.TXT):

DS1921:  6B00000010420521
Download at: 6/30/05 6:06:20 PM

Mission State
-------------
Mission is in progress
Sample rate: 5 minute(s)
Roll-Over Enabled: no
Roll-Over Occured: n/a
Mission Start time:  06/15/2005  05:59 
Mission Start delay: 0 minute(s)
Mission Samples: 4468
Device total samples: 172487
Temperatures displayed in: (Celsius)
High Threshold: -40.0°C
Low Threshold: -40.0°C
Temperature threshold alarm state: Conditional(H,L)  Alarm(H)
Current Real-Time Clock from DS1921: Thursday  06/30/2005  18:14:21 
Current PC Time: Thursday  06/30/2005  18:14:36 
Time Alarm mode: Alarm weekly
Alarm Time: Sunday 00:00:00
Alarm Time state: Conditional(yes)  Alarm(yes)

Temperature Alarms
------------------
Format: [(HIGH/LOW), Time/Date range]
HIGH ,  06/15/2005  05:59  to  06/16/2005  03:09 
HIGH ,  06/16/2005  03:14  to  06/17/2005  00:24 
HIGH ,  06/17/2005  00:29  to  06/17/2005  21:39 
HIGH ,  06/17/2005  21:44  to  06/18/2005  18:54 
HIGH ,  06/18/2005  18:59  to  06/19/2005  16:09 
HIGH ,  06/19/2005  16:14  to  06/20/2005  13:24 
HIGH ,  06/20/2005  13:29  to  06/21/2005  10:39 
HIGH ,  06/21/2005  10:44  to  06/22/2005  07:54 
HIGH ,  06/22/2005  07:59  to  06/23/2005  05:09 
HIGH ,  06/23/2005  05:14  to  06/24/2005  02:24 
HIGH ,  06/24/2005  02:29  to  06/24/2005  23:39 
HIGH ,  06/24/2005  23:44  to  06/25/2005  20:54 

Temperature Histogram
---------------------
Format: [Temp Range , Count] (Celsius)
-40.0°C to -38.5°C, 0
-38.0°C to -36.5°C, 0
-36.0°C to -34.5°C, 0
-34.0°C to -32.5°C, 0
-32.0°C to -30.5°C, 0
-30.0°C to -28.5°C, 0
-28.0°C to -26.5°C, 0
-26.0°C to -24.5°C, 0
-24.0°C to -22.5°C, 0
-22.0°C to -20.5°C, 0
-20.0°C to -18.5°C, 0
-18.0°C to -16.5°C, 0
-16.0°C to -14.5°C, 0
-14.0°C to -12.5°C, 0
-12.0°C to -10.5°C, 0
-10.0°C to -8.5°C, 0
-8.0°C to -6.5°C, 0
-6.0°C to -4.5°C, 0
-4.0°C to -2.5°C, 0
-2.0°C to -0.5°C, 0
0.0°C to 1.5°C, 0
2.0°C to 3.5°C, 0
4.0°C to 5.5°C, 0
6.0°C to 7.5°C, 79
8.0°C to 9.5°C, 116
10.0°C to 11.5°C, 141
12.0°C to 13.5°C, 110
14.0°C to 15.5°C, 364
16.0°C to 17.5°C, 560
18.0°C to 19.5°C, 589
20.0°C to 21.5°C, 298
22.0°C to 23.5°C, 403
24.0°C to 25.5°C, 274
26.0°C to 27.5°C, 418
28.0°C to 29.5°C, 622
30.0°C to 31.5°C, 308
32.0°C to 33.5°C, 178
34.0°C to 35.5°C, 6
36.0°C to 37.5°C, 0
38.0°C to 39.5°C, 0
40.0°C to 41.5°C, 0
42.0°C to 43.5°C, 0
44.0°C to 45.5°C, 0
46.0°C to 47.5°C, 0
48.0°C to 49.5°C, 0
50.0°C to 51.5°C, 0
52.0°C to 53.5°C, 0
54.0°C to 55.5°C, 0
56.0°C to 57.5°C, 0
58.0°C to 59.5°C, 0
60.0°C to 61.5°C, 0
62.0°C to 63.5°C, 0
64.0°C to 65.5°C, 0
66.0°C to 67.5°C, 0
68.0°C to 69.5°C, 0
70.0°C to 71.5°C, 0
72.0°C to 73.5°C, 0
74.0°C to 75.5°C, 0
76.0°C to 77.5°C, 0
78.0°C to 79.5°C, 0
80.0°C to 81.5°C, 0
82.0°C to 83.5°C, 0
84.0°C to 85.5°C, 0

Log Data
--------
Format: [Time/Date , Temperature] (Celsius)
 06/15/2005  05:59 , 21.5°C
 06/15/2005  06:04 , 21.5°C
 06/15/2005  06:09 , 21.5°C
 06/15/2005  06:14 , 21.5°C
 06/15/2005  06:19 , 22.0°C
 06/15/2005  06:24 , 22.5°C
 06/15/2005  06:29 , 23.0°C
 06/15/2005  06:34 , 22.5°C
 06/15/2005  06:39 , 22.5°C
 06/15/2005  06:44 , 22.5°C
 06/15/2005  06:49 , 22.5°C
 06/15/2005  06:54 , 22.5°C
 06/15/2005  06:59 , 22.5°C

. . .
 06/22/2005  07:54 , 14.5°C
 06/22/2005  07:59 , 14.5°C
 06/22/2005  08:04 , 14.5°C
 06/22/2005  08:09 , 14.5°C
 06/22/2005  08:14 , 14.5°C
 06/22/2005  08:19 , 14.5°C
 06/22/2005  08:24 , 14.5°C
 06/22/2005  08:29 , 14.5°C
 06/22/2005  08:34 , 14.5°C

Debug Dump (optional)
---------------------
Register Page:
21 14 18 05 30 86 05 00 00 00 01 00 00 05 07 00 
00 8C 00 00 A3 59 05 15 06 05 74 11 00 C7 A1 02 
Alarms:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
01 00 00 FF 00 01 00 FF FF 01 00 FF FE 02 00 FF 
FD 03 00 FF FC 04 00 FF FB 05 00 FF FA 06 00 FF 
F9 07 00 FF F8 08 00 FF F7 09 00 FF F6 0A 00 FF 
Histogram:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 4F 00 
74 00 8D 00 6E 00 6C 01 30 02 4D 02 2A 01 93 01 
12 01 A2 01 6E 02 34 01 B2 00 06 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
Log:
7B 7B 7B 7B 7C 7D 7E 7D 7D 7D 7D 7D 7D 7D 7C 7C 
7D 7D 7E 7D 7E 7E 7E 7F 80 80 80 7F 7E 7E 7E 7E 
7E 92 89 83 82 85 87 87 87 87 88 89 89 8A 8A 8A 
8B 8B 8B 8B 8B 8C 8D 8D 8D 8E 8C 8B 8B 8B 8B 8B 
8B 8C 8C 8C 8D 8D 8D 8D 8F 8F 8F 8F 8F 90 8F 90 
8F 8E 8C 8C 8D 8E 8E 8E 8E 8D 8C 8D 8E 8C 8D 8E 
8F 8F 91 91 8F 8F 8F 8F 8F 90 90 91 91 90 8F 8E 
8F 8F 8E 8F 8F 8F 8F 8F 90 90 90 90 90 90 91 90 
91 91 91 90 90 90 90 90 90 90 90 91 91 90 90 90 
90 90 91 92 91 91 90 90 90 8F 8E 8D 8D 8D 8F 90 
8F 8E 8E 8D 8D 8D 8C 8B 8A 8B 8C 8C 8C 8C 8B 8C 
8C 8D 8B 89 89 8A 89 89 8B 8C 8E 90 91 90 90 90 
90 90 90 90 90 90 90 8F 8E 8F 8F 8F 90 90 90 90 
90 8F 8E 8F 91 91 90 90 90 92 90 90 92 90 90 91 
92 92 92 94 8F 8F 90 8F 90 8F 8D 8C 8D 90 92 90 
90 90 8E 8D 8B 8B 8B 8C 8C 8D 8E 8E 8E 8E 8E 8F 
8F 8D 8D 8E 8E 8D 8E 8E 8D 8C 8C 8B 8B 8C 8D 8C 
8D 8F 90 8E 90 90 8F 8D 8C 8F 90 90 8D 8D 8E 8F 
8E 8E 8E 8E 8F 8F 90 90 90 8F 8E 8F 8E 8F 8E 8C 
8C 8D 8F 8F 8F 8F 91 90 90 90 90 90 91 90 90 90 
90 91 90 90 90 90 90 90 8E 8E 8F 8F 8F 90 91 90 
91 92 91 91 91 8F 8F 8F 90 8F 8F 91 90 8D 8C 8C 
8D 8F 91 90 8F 8F 8F 8E 8D 8D 8E 8E 8F 90 90 90 
8F 90 90 90 90 90 90 91 90 91 92 92 92 93 94 94 
95 92 91 92 94 94 92 93 93 93 93 93 92 90 8F 90 
8F 8F 8F 8F 90 90 91 90 90 90 91 91 90 90 90 8F 
90 8E 8E 91 91 91 91 91 90 90 8E 8D 8F 90 90 8F 
90 8F 8F 8F 91 91 92 91 90 91 8F 8E 8E 8E 8E 8C 
8C 8C 8C 8D 8D 8D 8D 8C 8D 8E 8C 8D 8D 8D 8E 8E 
8D 8B 8A 8A 8B 8B 8C 8C 8C 8C 8B 8B 8B 8B 8C 8D 
8C 8A 8A 8A 8A 8C 8B 8C 8B 8B 8A 8B 8C 8C 8B 8C 
8C 8C 8C 8D 8C 8C 8B 8B 8C 8D 8D 8C 8C 8C 8B 8C 
8B 8C 8C 8C 8B 8B 8D 8B 8A 8A 8A 8A 8C 8D 8E 8E 
8E 8B 88 88 89 8A 8B 8B 8B 8B 8B 8A 89 8A 8C 8C 
8B 8A 8A 88 87 88 8A 8A 8B 87 88 89 89 89 8A 8B 
8C 8B 89 88 89 8B 8B 8A 88 89 8A 8B 8A 89 8B 8B 
8D 87 86 87 86 8A 8B 8C 8D 8E 8B 87 89 8C 8D 8E 
8E 8D 8D 8A 8B 88 89 88 89 8B 8B 89 89 8A 89 8B 
8A 88 88 89 89 89 8A 8A 89 8A 89 89 8A 8B 8B 8C 
8B 88 87 88 89 88 89 8B 8B 8A 8A 8B 8B 8B 8C 8C 
8C 8D 8D 8D 8C 8C 8D 8D 8C 8B 8B 8B 8C 8B 8B 8B 
8A 8B 8B 8B 89 88 89 8B 89 88 88 89 88 89 8A 88 
8A 8A 89 89 8B 8B 8B 8A 8B 8C 8C 8B 8C 8D 8C 8D 
8A 8C 8C 8D 8C 8A 8C 8A 8A 8B 89 89 89 88 89 88 
89 89 89 8A 8A 89 89 89 89 89 89 88 89 89 89 89 
89 89 88 8B 8C 8B 8B 8B 89 88 88 86 86 88 8A 8C 
8C 8C 8B 8C 8C 89 89 8C 8B 89 89 89 8A 8A 89 87 
85 86 86 87 87 88 88 89 89 89 89 89 89 8A 8C 8E 
8D 8D 8B 8A 8A 89 8C 8B 8A 8A 8A 89 8A 8C 8B 89 
8A 8A 89 8A 8B 8A 8B 89 89 89 8A 89 89 87 87 86 
87 88 88 87 87 87 88 87 88 89 89 89 8A 8A 8A 8B 
8B 8B 8B 8B 8B 8A 8A 8A 8A 8A 8C 8A 8A 88 88 87 
86 86 86 87 88 89 88 88 88 89 87 88 89 89 89 88 
87 86 86 87 87 87 86 84 85 84 85 86 88 89 8A 88 
88 86 85 87 88 89 8A 8A 8B 89 89 89 88 89 88 89 
8A 8B 8B 8B 8B 8A 88 88 88 89 89 88 88 8A 8C 8C 
89 88 88 88 88 88 88 88 87 87 88 87 86 86 87 86 
85 83 84 85 85 86 87 88 87 88 89 89 87 85 85 87 
85 84 84 85 83 82 82 83 84 83 82 83 82 83 84 85 
85 86 87 88 88 89 88 89 89 8A 89 89 89 8A 8A 8A 
89 8A 8A 8A 8B 8A 8A 89 88 89 89 8C 8A 89 89 89 
89 89 89 89 89 89 88 88 88 89 89 8A 89 89 89 8A 
8A 89 8A 8A 88 88 88 87 88 89 88 88 88 88 88 89 
89 89 8A 8A 8A 89 86 88 89 89 88 88 87 89 89 8A 
8A 8C 8B 8A 87 86 86 87 86 84 84 84 84 84 85 87 
85 85 85 84 86 88 88 87 87 87 88 88 89 88 89 89 
89 89 89 89 8A 8A 8A 8A 8B 88 88 88 89 88 88 89 
89 89 87 86 86 85 86 88 8A 89 89 88 88 88 88 87 
87 88 87 87 88 88 88 87 88 88 88 86 87 88 87 88 
87 86 85 84 85 86 87 88 88 85 84 85 85 84 83 82 
82 84 84 83 83 83 83 83 84 84 83 84 84 84 84 84 
84 84 84 84 84 83 82 82 81 82 81 7F 7F 7F 7E 7F 
80 81 80 81 81 82 82 82 82 82 80 82 83 83 83 85 
83 83 81 81 81 81 81 81 81 83 83 84 84 82 83 83 
84 85 84 83 83 82 82 83 82 83 82 81 83 84 84 82 
81 83 83 83 83 82 82 83 82 84 83 83 83 83 83 84 
84 85 85 85 85 85 85 86 86 88 87 87 87 86 87 87 
87 88 89 88 87 87 88 88 88 88 88 88 89 89 88 88 
89 88 88 89 88 88 89 89 89 8A 8B 8A 89 89 89 89 
8A 8A 8A 8A 8A 8B 8B 8B 8C 8B 8B 8C 8C 8C 8C 8D 
8C 8B 8C 8B 8C 8B 8B 8B 8B 8B 8B 8A 8A 89 8A 8A 
8A 8A 8A 89 8A 8A 8B 8B 8B 8C 8C 8C 8B 8B 89 89 
89 89 8A 8A 89 87 87 87 87 87 88 88 88 88 87 86 
86 87 86 85 86 86 86 86 87 86 86 86 87 87 87 87 
87 87 86 86 86 87 87 88 89 89 89 88 87 89 89 88 
88 86 86 86 86 86 86 87 88 86 86 87 87 87 87 86 
87 86 87 88 88 88 88 88 88 88 86 85 85 85 85 85 
85 85 84 84 84 85 85 85 85 86 85 85 85 86 85 85 
86 87 87 87 87 88 87 87 87 87 87 87 87 87 87 87 
88 88 89 89 89 88 87 85 84 82 84 84 83 81 80 7F 
7E 7E 7E 7E 7F 7F 7E 7C 7D 7E 7F 7D 7E 7F 7F 7E 
7E 7F 7E 7D 7D 7C 7B 7B 7C 7D 7E 7F 7E 7E 7F 7F 
81 82 82 81 80 80 81 81 80 7F 7E 7E 7F 7F 7F 7F 
80 7F 80 80 80 7F 7D 7C 7D 7D 7D 7C 7C 7D 7E 7E 
7F 7F 7F 7E 7B 79 78 77 76 76 76 75 75 75 75 75 
75 75 76 77 77 78 78 79 79 79 79 7A 7A 7B 7C 7D 
7D 7E 7E 7E 7D 7D 7C 7C 7C 7B 7B 7B 7B 7B 7A 7B 
7A 7A 7B 7B 7C 7D 7E 7D 7E 7F 7E 7D 7D 7D 7C 7C 
7B 7B 7B 7B 7B 7B 7B 7A 7A 7A 79 79 79 79 78 78 
78 78 78 77 77 77 77 77 76 76 76 76 76 76 75 75 
75 75 75 75 74 74 74 74 74 73 73 73 73 73 72 72 
72 72 72 72 71 71 71 71 70 70 70 70 70 6F 6F 6F 
6F 6E 6E 6E 6E 6E 6D 6D 6D 6D 6D 6C 6C 6C 6C 6C 
6B 6B 6B 6B 6B 6B 6B 6A 6A 6A 6A 6A 6A 69 69 69 
69 69 69 69 69 68 68 68 68 68 68 68 68 68 67 67 
67 67 67 67 67 67 67 66 66 66 66 66 66 66 66 66 
65 65 65 65 65 65 65 65 65 65 65 64 64 64 64 64 
64 64 64 64 64 64 64 64 63 63 63 63 63 63 63 63 
63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 
63 63 63 64 64 64 64 64 64 64 65 65 65 65 66 66 
66 66 67 67 67 68 68 68 69 69 69 69 6A 6A 6B 6B 
6C 6C 6D 6E 6E 6F 6F 70 70 70 71 71 71 72 72 73 
73 73 74 74 75 75 75 75 75 75 75 75 75 75 75 75 
76 76 77 78 78 79 7A 7A 7A 7B 7B 7B 7C 7D 7E 7E 
7F 7F 80 80 7F 7F 7E 7E 7D 7D 7D 7C 7C 7C 7C 7C 
7B 7B 7C 7C 7D 7E 7E 7E 7F 7F 7F 7E 7D 7D 7C 7C 
7C 7C 7B 7B 7A 7A 7A 7A 79 79 79 79 78 78 78 78 
77 77 77 77 77 77 76 76 76 76 75 75 75 75 75 75 
74 74 74 74 74 74 74 73 73 73 73 73 73 73 73 72 
72 72 72 72 72 72 72 72 72 71 71 71 71 71 71 71 
71 71 71 71 70 70 70 70 70 70 70 70 70 70 70 70 
70 70 6F 6F 6F 6F 6F 6F 6F 6F 6F 6F 6F 6F 6F 6F 
6F 6F 6F 6F 6F 6F 6F 6F 6F 6F 6F 6F 6F 6F 6F 6E 
6E 6E 6E 6E 6E 6E 6E 6E 6E 6E 6E 6E 6E 6E 6E 6E 
6E 6E 6E 6E 6E 6E 6E 6E 6E 6E 6E 6E 6E 6E 6D 6D 
6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 
6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 
6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 


0

Response Number 5
Name: jbmellophone
Date: June 9, 2009 at 09:19:58 Pacific
Reply:


And here's what it should look like when I'm done(2005BB1C1_Aconvo):

6/15/2005	5:59	21.5
6/15/2005	6:04	21.5
6/15/2005	6:09	21.5
6/15/2005	6:14	21.5
6/15/2005	6:19	22
6/15/2005	6:24	22.5
6/15/2005	6:29	23
6/15/2005	6:34	22.5

. . . 
6/22/2005	8:04	14.5
6/22/2005	8:09	14.5
6/22/2005	8:14	14.5
6/22/2005	8:19	14.5
6/22/2005	8:24	14.5
6/22/2005	8:29	14.5
6/22/2005	8:34	14.5

Thanks a bunch, I really appreciate it! Without this script, it was certainly going to take me all summer to do all these files by hand, and that's only the first step of what I need to do to them all! Thanks again! :-)


0

Related Posts

See More



Response Number 6
Name: ghostdog
Date: June 9, 2009 at 17:06:45 Pacific
Reply:

import os,glob
for files in glob.glob("file.txt"):
    f=open(files)
    g=0
    for line in f:
        if "Debug Dump" in line:break
        if "Format: [Time/Date" in line:
            g=1
            continue
        if g:
            try:
                d,t,temp = line.strip().replace(",","").split()
            except:pass
            else:
                if t.startswith("0"):
                    t = t.replace("0","")                
                print d,t,temp.strip("\xb0C")
    f.close()   


0

Response Number 7
Name: jbmellophone
Date: June 10, 2009 at 07:25:49 Pacific
Reply:

That's awesome, thanks! The only thing is that it's taking the zeros out of the times, like 6:04 and 6:09 become 6:4 and 6:9. I don't really need the primary zeros removed,(I checked that the program would still run with them there and it does,) I didn't actually notice that they were missing - apparently that's just something that Excel does with the paste function. Good eye there! :-) So I commented those two lines out, and it works great!

I'm talking with my advisors about whether to put all the data in a single file, or if I should do separate files . . . but I think I should be able to handle that much! :-) Thank you so much, I really appreciate it! :-)


0

Response Number 8
Name: ghostdog
Date: June 10, 2009 at 09:06:04 Pacific
Reply:

>>The only thing is that it's taking the zeros out of the times, like 6:04 and 6:09 become 6:4 and 6:9.

ok then change this:

                if t.startswith("0"):
                    t = t.replace("0","")       

to

                if t.startswith("0"):
                    t = t[1:] #so that it won't replace all 0's

you should understand what i am doing by now :)

0

Response Number 9
Name: jbmellophone
Date: June 10, 2009 at 09:18:01 Pacific
Reply:

Yes I do! Thanks!!! :-)


0

Sponsored Link
Ads by Google
Reply to Message Icon

adding a movie/flash back... AppleScript: Start and st...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: complicated file creation in Python

Determine length of file in Python www.computing.net/answers/programming/determine-length-of-file-in-python/11903.html

operate several files in python? www.computing.net/answers/programming/operate-several-files-in-python/14508.html

opening an image in python www.computing.net/answers/programming/opening-an-image-in-python/14922.html