473,396 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

CVS file problem.

  1. #! /usr/bin/env python
  2. import MySQLdb
  3. import re
  4. import csv
  5. db=MySQLdb.connect(host='localhost', db='dbase', user='root',
  6. passwd='pass')
  7. c=db.cursor()
  8. c.execute('SELECT text FROM tabelle WHERE page_title = "articles"
  9. result = c.fetchall()
  10. f = csv.writer(open( "text1.txt","w" ))
  11. for line in result:
  12. f.writerow(line)
  13. file= open("text1.txt","rb")
  14. for line in file.readlines():
  15. p = re.compile(r'\[\[(.*?)\]\](.*?)[(\\\n\*\+)]')
  16. #p = line.replace("\(\)" , " ")
  17. result = p.findall(line)
  18. f = csv.writer(open("text2.txt" , "w").writerow(str(result))

I do not have line 39 on my programm

File "page_query_test.py", line 39

^
SyntaxError: invalid syntax
May 4 '10 #1
3 4096
woooee
43
Expand|Select|Wrap|Line Numbers
  1. f = csv.writer(open("text2.txt" , "w").writerow(str(result))
Check the number of left parens and right parens in this statement. I good IDE will assist with closing any punctuation you begin.
May 4 '10 #2
I see but i have now this error message
Traceback (most recent call last):
File "page_query_test.py", line 28, in <module>
f = csv.writer(open("wikiparsedexp.txt" , "w").writerow(str(result)))
AttributeError: 'file' object has no attribute 'writerow'
May 4 '10 #3
v0id
3
the error msg's pretty self-explanatory isn't it?

f = csv.writer(open("wikiparsedexp.txt","w").writerow(str(result)))

AttributeError: 'file' object has no attribute 'writerow'
May 5 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: Sean Ross | last post by:
Hi. Recently I made a small script to do some file transferring (among other things). I wanted to monitor the progress of the file transfer, so I needed to know the size of the files I was...
9
by: Hans-Joachim Widmaier | last post by:
Hi all. Handling files is an extremely frequent task in programming, so most programming languages have an abstraction of the basic files offered by the underlying operating system. This is...
7
by: Keith Dewell | last post by:
Greetings! My current job has brought me back to working in C++ which I haven't used since school days. The solution to my problem may be trivial but I have struggled with it for the last two...
11
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own...
4
by: SS | last post by:
We built an MSI file to deploy a .net app to the workstation. We created an HTML page that has a link to the MSI file. On a very sporadic basis, when the MSI is run we get the following message:...
5
by: David Webb | last post by:
The problem started when the Working Folder for a project was somehow set to the folder of another project. I set the correct working folder in VSS and deleted the .vbproj files that had been...
8
by: Sarah | last post by:
I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my...
17
by: Peter Duniho | last post by:
I searched using Google, on the web and in the newsgroups, and found nothing on this topic. Hopefully that means I just don't understand what I'm supposed to be doing here. :) The problem: ...
4
by: pradqdo | last post by:
Hi folks, I have a very strange problem when I try to port my client/server program to cygwin. It is a simple shell program where the server executes client's commands + it can send and receive...
4
by: Salad | last post by:
I have a situation where some, not all, users get the message "Couldn't find file "F:\AccessApps\AppName.mdw". This file is required for startup". My app the users are attempting to access is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.