[Tutor] Searching for time in a given string

2010-04-01 Thread Judith Flores
Hello, I was wondering if someone could provide me with the pattern syntax to find the time in a given string. The time usually appears as "14:28:32" (for example) within a string ("Sun Jan 23 14:28:32 1965"). How can I retrieve the time? Thank you very much in advance for your help, Judi

[Tutor] Difference in minutes between two time stamps

2009-03-02 Thread Judith Flores
Hello, I can't seem to figure out the syntax to calculate the difference in minutes between two time stamps. I already read the documentation about datetime and time modules, but I was unable to implement the code. My code will be fed with two timestamps (as styrings): start="09:35:23" end

[Tutor] Documentation on how to run complete R scripts from Python interpreter

2008-11-12 Thread Judith Flores
Hello, I am very new to Python and I have long R scripts that I would like to run under the Python Interpreter. The reason for this is because I will try to construct a GUI using 'easygui' in Python. I read some of the the documentation regarding the RPy module, but it implies to add a 'r' a

[Tutor] Subprocess module

2008-11-26 Thread Judith Flores
Hello, A couple of weeks ago I posted a question about what documentation I should read in order to implement a way to communicate Python and R. I read about the module 'subprocess', but have not been able to do something very simple. I was wondering if you could tell me how to transfer a Py

[Tutor] Making a dictionary of dictionaries from csv file

2008-12-02 Thread Judith Flores
Dear Python community, I have been trying to create a dictionary of dictionaries (and more dictionaries) from a csv file. The csv file contains longitudinal data corresponding to names. The following is just a very (very) simple example of how the data looks: NameDayweighttemp name114537 na

[Tutor] Modify a dictionary using csv.DictWriter

2009-01-12 Thread Judith Flores
Hello, I have been struggling a while trying to figure out how to modify a csv file using the csv.DictWriter class. Let's suppose I have the following code: import csv outfile=open('template.csv','w') # This is a pre-existing file that contains 3 variables (3 columns). The variables will

[Tutor] Writing long strings (that include commas) to a csv file

2009-01-22 Thread Judith Flores
Hello dear Python experts, How can I write a complete string (which sometimes will include many commas) to a cell in a CSV file? With the code below, what I obtain is a cell per letter of every string: file1=open('myfile.csv','w') writer=csv.writer(file1) mylist=[ " first , txt+words , more"

[Tutor] How to avoid error message: "_csv.Error: new-line character seen in unquoted field - do you need to open the file in universal-newline mode?"

2009-02-06 Thread Judith Flores
Hello, I get the error message above quite often when trying to open some csv files. I noticed that if I open the csv file in excel and delete the "empty" columns at the right end of my data, the error message doesn't appear. My code looks like this: myfile=open(csvfile) reader=csv.reader(m