I want to parse through and create a single file from CSV files generated from Blackberry Messenger.
An example :
BlackBerry Messenger,6.0.0.129CRLF
201112071323251405361,"2732E6DB ","555ABCDA",TextData TextData TextData TextDataCRLF
201112071323253558103,"555ABCDA","2732E6DB ",TextData TextData TextDataCRLF
201112071323253746576,"2732E6DB ","555ABCDA",TextData TextData TextData
LF
TextData TextDataLF
TextData TextData TextData TextData TextData TextData TextData TextData TextDataLF
TextData TextData TextData TextDataCRLF
201112071323253809444,"2732E6DB ","555ABCDA", TextData TextData TextData TextDataCRLF
201112091323441592335,"2732E6DB ","555ABCDA", TextData TextDataLF
LF
<3<3=.>:O :s=.>=) <3<3=.>:O :s=.>=)LF
LF
- Copy all smiley aboveLF
- pasteLF
- erase 4 dotLF
- send me backLF
- see the magic (smiley change)LF
CRLF
As you can see that CSV file has following format
Date,SendersPIN,ReceiversPIN,MessageText
Date is in YYYYMMDD+epoch format. Every record ends with a CRLF (carriage return line feed) characters, while each new line in MessageText is separated by LF (line feed) character.
As you can see the problem is that MessageText is not contained in any container and it may have many new lines. So I cant import it in excel directly.
I would consider myself beginner in PHP as far as file operations are concerned, so if possible try to describe the code.
Thank you.
As @xbonez says, this is very tricky to do. I think you need to read each line at a time. The date in the first "column" may be your trick to determining where a new message begins. This won't be PHP code, but the method I would use:
The
new_bbm_message
function is something you get to write to determine if the line is the start of a new BBM message (returns TRUE if the line is a new message or FALSE if it is the continuation of the message one). You can either try to change the first 20 characters of the line into a valid date in PHP, or test whether position 21 is a comma.You need to double check some of the numbers for the substr calls, they may be off.
Good Luck.