Search Results

Search found 8 results on 1 pages for 'thinkcode'.

Page 1/1 | 1 

  • How to Convert multiple sets of Data going from left to right to top to bottom the Pythonic way?

    - by ThinkCode
    Following is a sample of sets of contacts for each company going from left to right. ID Company ContactFirst1 ContactLast1 Title1 Email1 ContactFirst2 ContactLast2 Title2 Email2 1 ABC John Doe CEO [email protected] Steve Bern CIO [email protected] How do I get them to go top to bottom as shown? ID Company Contactfirst ContactLast Title Email 1 ABC John Doe CEO [email protected] 1 ABC Steve Bern CIO [email protected] I am hoping there is a Pythonic way of solving this task. Any pointers or samples are really appreciated! p.s : In the actual file, there are 10 sets of contacts going from left to right and there are few thousand such records. It is a CSV file and I loaded into MySQL to manipulate the data.

    Read the article

  • How do I convert tuple of tuples to list in one line (pythonic)?

    - by ThinkCode
    query = 'select mydata from mytable' cursor.execute(query) myoutput = cursor.fetchall() print myoutput (('aa',), ('bb',), ('cc',)) Why is it (cursor.fetchall) returning a tuple of tuples instead of a tuple since my query is asking for only one column of data? What is the best way of converting it to ['aa', 'bb', 'cc'] ? I can do something like this : mylist = [] myoutput = list(myoutput) for each in myoutput: mylist.append(each[0]) I am sure this isn't the best way of doing it. Please enlighten me!

    Read the article

  • Help converting code using httlib2 to use urllib2

    - by ThinkCode
    What am I trying to do? Visit a site, retrieve cookie, visit the next page by sending in the cookie info. It all works but httplib2 is giving me one too many problems with socks proxy on one site. http = httplib2.Http() main_url = 'http://mywebsite.com/get.aspx?id='+ id +'&rows=25' response, content = http.request(main_url, 'GET', headers=headers) main_cookie = response['set-cookie'] referer = 'http://google.com' headers = {'Content-type': 'application/x-www-form-urlencoded', 'Cookie': main_cookie, 'User-Agent' : USER_AGENT, 'Referer' : referer} How to do the same exact thing using urllib2 (cookie retrieving, passing to the next page on the same site)? Thank you.

    Read the article

  • How do I do this in Python (File Manipulation)?

    - by ThinkCode
    I have a bunch of HTML files in HTML folder. Those HTML files have unicode characters which I solved by using filter(lambda x: x in string.printable, line). Now how do I write the changes back to the original file? What is the best way of doing it? Each HTML file is of 30 kb in size. 1 import os, string 2 3 for file in os.listdir("HTML/"): 4 print file 5 myfile = open('HTML/' + file) 6 fileList = myfile.readlines() 9 for line in fileList: 10 #print line 11 line = filter(lambda x: x in string.printable, line) 12 myfile.close()

    Read the article

  • What programming screencasts/podcast resources do you know?

    - by Ricky AH
    Just as the title says, if you know any resource, answer here. Personally I'm more0interested in screencasts more than podcasts, because english is not my mother tonge, so visual clues help a lot: NetBeans TV Screencasts DimeCasts.NET Apple Developer Connection (iTunes) --- Suggested by the community .NET Rocks dnrTV Channel9 MSDN Events and WebCasts Software Engineering DeepFries RailCasts Learnivore! HanselMinutes ThinkCode

    Read the article

1