Parsing a Text Input Field
Posted: Tue Jul 08, 2008 12:51 pm
I know I've 'gotta be missing something simple here, but I've spent hours scouring Google, and have tried to figure this out on my own, but I'm just drawing blanks.
I need to write a script that basically converts a log output into something that I can import into a mySQL database. The log will be copy-pasted into a text field, and parsed from there. Although this won't be the final application, here's a basic example:
Log File:
Monday:
John (employee #5) 6 hours
Bill (employee #67) 2 hours
Steve (employee #12) 8 hours
Tuesday:
Jack (employee #22) 8 hours
John (employee #5) 2 hours
Bill (employee #67) 6 hours
Wednesday:
Steve (employee #12) 8 hours
Jack (employee #22) 8 hours
----
The script needs to take an input like that and create database rows with just two columns, Employee Name and Time Worked. Up to this point, I know how the script will work. However, it needs to combine all instances of an employee's name into a single row, and I'm not sure how to do that.
For example, the final result in the database will be (Name and then Time):
John 8
Bill 8
Steve 16
Jack 16
Thanks,
Adam
I need to write a script that basically converts a log output into something that I can import into a mySQL database. The log will be copy-pasted into a text field, and parsed from there. Although this won't be the final application, here's a basic example:
Log File:
Monday:
John (employee #5) 6 hours
Bill (employee #67) 2 hours
Steve (employee #12) 8 hours
Tuesday:
Jack (employee #22) 8 hours
John (employee #5) 2 hours
Bill (employee #67) 6 hours
Wednesday:
Steve (employee #12) 8 hours
Jack (employee #22) 8 hours
----
The script needs to take an input like that and create database rows with just two columns, Employee Name and Time Worked. Up to this point, I know how the script will work. However, it needs to combine all instances of an employee's name into a single row, and I'm not sure how to do that.
For example, the final result in the database will be (Name and then Time):
John 8
Bill 8
Steve 16
Jack 16
Thanks,
Adam