473,396 Members | 1,972 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.

Import question

2
Hello,

I am very, very new at this, new at programming in general actually. This is probably a very simple question, but I need to start somewhere.

I am trying to use a python script as part of the HEC-DSSVue software package to write and extract from the DSS database. I need to read in a csv file to then write to the database.

The HEC-DSSVue software includes a simple python script editor. If my understanding is correct, I need to import the csv module. I am using:

Expand|Select|Wrap|Line Numbers
  1. import csv
This yields a ImportError: no module named csv.

Other script imports have been:

Expand|Select|Wrap|Line Numbers
  1. from hec.script import*
I am just guessing that I need to set something up in the CMD file, but I am not sure what it should be. Any help would be very much appreciated.

Thanks.
Jul 25 '07 #1
1 1749
bvdet
2,851 Expert Mod 2GB
Hello,

I am very, very new at this, new at programming in general actually. This is probably a very simple question, but I need to start somewhere.

I am trying to use a python script as part of the HEC-DSSVue software package to write and extract from the DSS database. I need to read in a csv file to then write to the database.

The HEC-DSSVue software includes a simple python script editor. If my understanding is correct, I need to import the csv module. I am using:

Expand|Select|Wrap|Line Numbers
  1. import csv
This yields a ImportError: no module named csv.

Other script imports have been:

Expand|Select|Wrap|Line Numbers
  1. from hec.script import*
I am just guessing that I need to set something up in the CMD file, but I am not sure what it should be. Any help would be very much appreciated.

Thanks.
Have you installed Python on your system? Does the file csv.py exist on your system. Check your path:
Expand|Select|Wrap|Line Numbers
  1. import sys
  2. for p in sys.path:
  3.     print p
If the file exists in one of these subdirectories and the subdirectory has an __init__.py file, it should import.

If the CSV file is simple, you may be able to write your own. E.G. this simple file:
1 01,02,05,07,18
2 00,01,04
3 09,20,21
4 12,34,56,77,88,99
5 03,05,77,88,54
The following code will create a dictionary from which you can write to your database:
Expand|Select|Wrap|Line Numbers
  1. def file_data1(f):
  2.     dd = {}
  3.     for line in f:
  4.         lineList = line.split()
  5.         dd[int(lineList[0])] = [int(i) for i in lineList[1].split(',')]
  6.     return dd
  7.  
  8. dd = file_data1(open('csv.txt').readlines())
Jul 26 '07 #2

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

Similar topics

1
by: Kevin MacKenzie | last post by:
I'm a complete newbie to using Python. I have a small question about importing modules. Is there any difference between the two following statements, and what (if any) are they? >>> from...
0
by: Stian Søiland | last post by:
all examples performed with: Python 2.3+ (#2, Aug 10 2003, 11:09:33) on linux2 (2, 3, 0, 'final', 1) This is a recursive import:
1
by: Raaijmakers, Vincent \(GE Infrastructure\) | last post by:
Question: my src path looks like this: src\root\sub1 src\root\sub2 My main code is in root, lets say main.py and there is also a lib.py. In sub1 there if foo1.py and sub2 foo2.py Sorry for...
3
by: Doug Baroter | last post by:
Hi, One of my clients has the following situation. They use Access DB for data update etc. some business functions while they also want to view the Access data quickly and more efficiently in...
2
by: jet | last post by:
Hi, Maybe this is an easy task, but I'm having a really hard time figuring out how to do this. I'm a complete newbie to SQL Server. I have a database dump file from MySQL that's in .sql...
2
by: Charles Fineman | last post by:
I've been asked to look over an integration toolkit that has a bunch of schemas to specify message format. There are a couple of strange things I noticed right off the bat and I wanted to get...
1
by: Dan | last post by:
Could someone please help me with auto importing a series of data files into an Access table. I tried to follow code given below in a previous messagebut i'm getting error messages. Here's my...
4
by: Bruce W. Roeser | last post by:
All, I'm reading a book by Charles Petzold (Programming VS.Net). Pretty good content but am confused about the difference. From the text: ...
3
by: SMALLp | last post by:
Hy! I'm new in Linux, and i feel little less newer in python. I need advice and help. I'm making an application witch purpose is irrelevant. It has a lot of code for now and I've only made...
0
by: 123bargains | last post by:
Hello, I have a question on importing a database from MSSQL 2000 to MSSQL 2005. I hope someone on here can help me answer it. I am trying to import a database from MSSQL 2000 to 2005. But, when I...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.