Python/CSV string help
Posted on 2014-09-21
So I am working with a CSV that has a many to one relationship and I have 2 problems I need assistance in solving. The first is that I have the string set up like
So I need to split the string twice, once on = and once on , as I am basically attempting to get the portion that is an e-mail address (email@example.com) so far I have figured out how to split the string on the = using something like this:
str = firstname.lastname@example.org,blah,blah,blah
Which returns this "email@example.com,blah,blah,blah"... however this leaves the ,blah,blah,blah portion to removed... after a ton of research I am stumped as nothing explains how to remove from the middle, just the 1st part or the last part. Does anyone know how to do this?
For the 2nd part I need to do this from multiple line, so this is more of an advice question... is it best to plug this into a variable and loop through like (i = 1, for i, #endofCSV do splitcmd) or is there a more efficient manner to do this? I am more familiar with LUA and I am learning that the more I work with python the more it differs from LUA.
Please help. Thanks!