Hi All, I am a newbie programmer in python and I am trying to read multiple csv files from a folder, replace the delimeter for all the csv files and then output these files into a new folder with replaced delimiter. So far I am stuck at the beginning. Please can someone point out some tips? Thanks!

Member Avatar
Member Avatar
+0 forum 5

Hi All, I have a task in Python where I need to move .csv files into a new folder. I tried using the below code but it was throwing me an error. import shutil import os source = os.listdir(r'C:\Users\mchalla\PycharmProjects\837_unzip\venv\SampleUnzipFiles\SampleZipFiles/') destination = 'C:\Users\mchalla\PycharmProjects\837_unzip\venv\SampleUnzipFiles\DelimitedFiles' for files in source: if files.endswith("_new.csv"): shutil.move(files,destination) Error Message: C:\Users\mchalla\PycharmProjects\837_unzip\venv\Scripts\python.exe C:/Users/mchalla/PycharmProjects/837_unzip/MoveFilesToNewFolder.py File "C:/Users/mchalla/PycharmProjects/837_unzip/MoveFilesToNewFolder.py", line 4 destination = 'C:\Users\mchalla\PycharmProjects\837_unzip\venv\SampleUnzipFiles\DelimitedFiles' ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape Process finished with exit code 1 Could someone please help me to solve this issue? Thank you!

Member Avatar
Member Avatar
+0 forum 4

**Usage:** Provides a secure frontend object with restricted access to attributes of the backend object.

Member Avatar
Member Avatar
+0 forum 1

Hello, I'm trying to use md5 in python3 using the attached code from hashlib import md5 password = 'pa$$w0rd' h = hashlib.md5() print(h.hexdigest()) put it gives me this error (cannot import name 'md5') and when i try to import hashlib only it gives this error (module 'hashlib' has no attribute 'md5') I searched everywhere but i cant find any solution to my case

Member Avatar
Member Avatar
+0 forum 4

Hello, Im trying to install pymongo package to be able to connect to MongoDB using pip pip install pymongo but it produce the below error Could not find a version that satisfies the requirement pymongo (from versions: ) No matching distribution found for pymongo

Member Avatar
Member Avatar
+0 forum 6

Hello, i have a sample web appliaction which get a value from HTML text feild and redirect to HTML page according to the value passed but the problem is that i can't get the value entered in the html text throught (request.form) method I get the below error werkzeug.routing.BuildError: Could not build url for endpoint 'suc'. Did you forget to specify values ['name']? from flask import Flask ,redirect, url_for, request app = Flask (__name__) @app.route('/suc/<name>') def suc(name): return "hello Boss %s" % name @app.route('/login', methods = ['GET','POST']) def login(): if request.method == 'post': user = request.form['nm'] return redirect(url_for('suc',name = user)) …

Member Avatar
Member Avatar
+0 forum 1

Hello I have created two classes one for the user and the other for address every thing is ok and the tables of the two classes created in my database but when i try to initiate a new object from user class i get the below error "sqlalchemy.exc.InvalidRequestError: Mapper 'Mapper|user|user' has no property 'address" from sqlalchemy import * from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import * db = create_engine('sqlite:///Test.db') Base = declarative_base() class user(Base): def __init__(self,name,password): self.name = name self.password = password def __repr__(self): return "(name = '%s', password = '%s' )" % (self.name,self.password) __tablename__ = 'user' id = Column(Integer …

Member Avatar
Member Avatar
+0 forum 2

Hello, I'm trying to write my first cookie on python but when i import cookie or even http.cookie it gives me the below error import cookie c = cookie.SimpleCookie() c["value"] = "first" print (c) ImportError: No module named 'cookie' [Finished in 0.3s with exit code 1] [shell_cmd: python -u "C:\Users\hohait\Desktop\test.py"] [dir: C:\Users\hohait\Desktop] [path: C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Common Files\NetSarang;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Lotus\Notes;C:\Program Files\IBM\Client Access\Emulator;C:\Program Files\IBM\Client Access\Shared;C:\Program Files\IBM\Client Access";C:\Users\hohait\AppData\Local\Programs\Python\Python35-32";C:\Users\hohait\AppData\Local\Programs\Python\Python35-32\Scripts\;C:\Users\hohait\AppData\Local\Programs\Python\Python35-32\;C:\Users\hohait\AppData\Local\Programs\Python\Python35-32]

Member Avatar
Member Avatar
+0 forum 4

This snippets contains a python program to find a shortest solution to the problem of the farmer who whishes to cross a river. The boat can only contain two things, including the rower. The farmer comes with a wolf, a duck and a bag of corn, and he can't leave the duck alone with one of the other items because the wolf would eat the duck, or the duck would eat the corn. The program shows how to use a `collections.OrderedDict` to implement a stack without repetitions. This is used to traverse a tree of states. These states, encoded as …

Member Avatar
Member Avatar
+0 forum 5

what is my best approach to deal with negative floating values in Python3? I know I can remove the negative all together with strip but I'd like to return the negative result if possible Example the following code returns a math domain error due to the negative number: eps = -2.1 bps = 5 def calc_grahamNum(self): ''' Graham Number Calculator ''' grahamNum = round(float(math.sqrt(22.5 * eps * bps)),2) return grahamNum

Member Avatar
Member Avatar
+0 forum 7

Hello. With running this command: `python manage.py validate` I faced with this error: `Unknown command: 'validate'` What should I do now? For more explanations: - Linux - Virtualenv - Python 3.4.3+ - Django (1, 9, 2, 'final', 0)

Member Avatar
Member Avatar
+0 forum 1

Fair warning - I'm still learning so this might be a very newb like question: What I'm trying to do: I'm trying to import a python file into a Tkinter window and run it when I press a button. Eventually I'd like to display the output of the imported script (yahooKeyStats) into a separate window and then save it to a text file but I am still learning how to do that The current issue: When I import "yahooKeyStats" then convert it to tsx for use within this script the yahooKeyStats module seems to run before the tkinter window is …

Member Avatar
Member Avatar
+0 forum 2

I'm hoping to create a scheduler based on data extracted from an Excel (2016) spreadsheet. At the moment I'm using Ubuntu 14.04 LTS with the desire to port the completed project to Android through Bulldozer. I like what I've heard about the simplicity of Pyqt. The completed project must work with Android. I have Android tablets running Lollipop and KitKat. I can develop using Ubuntu, Windows 7 & 10, Android, environments. What I need to know is if you think I will be working with the right combination of PyCharm, PyQT (if it will work with PyCharm?) and eventually Buildozer …

Member Avatar
+0 forum 0

I have been using Eric to develop Python2.7 code for a while. I have just tried to look at Python3 and cannot figure out how to do it in Eric. Setting > Preferences > Python says Python2 uses .py extension, Python3 uses .py3 I create hello.py3 #!/usr/bin/env python3 from platform import python_version print ('version info ', python_version()) If I run it in Eric I get ('version info ', '2.7.6') but if I run it in a terminal I get version info 3.4.3 How do I get Eric to use Python3? Thanks Mick

Member Avatar
Member Avatar
+0 forum 2

Hi guys, could you tell me how to solve this problem. This is what i've done. The result show : [9, 2, 6] [3, 9, 5] l1 = [4,9,2,6] l2 = [3,9,4,5] i = 0 j = 0 while(i < len(l1)): while(j < len(l2)): if(l1[i] == l2[j]): del(l1[i]) del(l2[j]) j += 1 i += 1 print(l1) print(l2)

Member Avatar
Member Avatar
+0 forum 2

Hey ya guys, it's my first topic on DaniWeb, sounds like a good place to find help with programming. :) Today I'm trying to compile a simple code made for PyQt4 using cx_Freeze, but I'm getting an error, I'll show you all the codes: [B]example.pyw[/B] [CODE]import sys from PyQt4 import QtGui def main(): app = QtGui.QApplication(sys.argv) w = QtGui.QWidget() w.resize(250, 150) w.move(300, 300) w.setWindowTitle('Example') w.show() sys.exit(app.exec_()) if __name__ == '__main__': main()[/CODE] [B]setup.py[/B] [CODE]from cx_Freeze import setup, Executable includes = ["sip","re"] exe = Executable( script="example.pyw", base="Win32GUI" ) setup( options = {"build_exe": {"includes":includes}}, executables = [exe] ) [/CODE] After compiling the code, …

Member Avatar
Member Avatar
+0 forum 7

Hello guys, I really need help with this one. Can you please help me create a program in Python that displays information about a rectangle of any size. Input: two mouse clicks for the opposite corners of a rectangle Output: Draw the rectangle. Print the perimeter and area of the rectangle Formulas: Area = (length)(width) Perimeter =2(length+width) Please help I just started using Python,

Member Avatar
Member Avatar
+0 forum 4

Hello there, I am currently working on a indepedendent project and I am realtively new to Python. Please note that this question revolves around Python version 3. But if you have a answer in Python 2 just write it down and tell me it is in Python 2 thanks. What I am trying to do is save a program from within so that when it is opened again it will have the stuff. Example Example = [] UserInputEx = input("Enter somethng here") #In this case I would enter HappyCodingDude #What ever command would be used here or someplace else to …

Member Avatar
Member Avatar
+0 forum 2

Hello good people, I wanted to talk today about auxiliary functions. I have a brief understanding of what it is, however, I am still rather confused on what it actually does. Lets say for example I have a function that calculates leapyear as TRUE or FALSE, how would I use it as an auxiliary function? How would it be incorporated into another functions, lets say one that determines whether or not a date is real or not. Many thanks for any claifications in advance.

Member Avatar
Member Avatar
+0 forum 3

What's a better way to do this? I need to sift through this file and store the following values Cpl File name Content kind Package type Encryption status Container File size Duration Timed text/png Number of audio channels 2d/3d Fps 1) I'm not sure if I should just store these as lists? 2) Should I use dictionaries ? Here's one sample file. [Click Here](http://tny.cz/aeca9b6c) And here's how I was attempting to sort through the file, with not as much luck as I would like. import glob import os import sys print(os.getcwd()) dir=raw_input(["Please enter directory location of dcp_inspect output"]) print (dir) …

Member Avatar
+0 forum 0

I'm trying to modify this code to take advantage of classes and some other oop features. However, I'm struggling with getting beyond the basics. This is the code that I started with which I am trying to change and make more class absed. import glob import os import sys print(os.getcwd()) dir= raw_input(["Please enter directory location of dcp_inspect output"]) print (dir) os.chdir(dir) print(os.getcwd()) cpl = [] content = [] errors = [] contentkind = [] summary = [] for file in glob.glob("*"): try: print (file,'\t Was Successfully Opened') #file = DcpParse() newfile = file print('Scanning...', newfile) data = open(newfile) for each_line …

Member Avatar
+0 forum 0

Hi, I have an output file (.txt) from a computational chemistry program. At some point in this file, following an unknown number of iterative steps, the following table will be found: Comparison of initial and final structures : -------------------------------------------------------------------------------- Parameter Initial value Final value Difference Units Percent -------------------------------------------------------------------------------- Volume a b c alpha beta gamma 1 x 1 y 1 z 2 x 2 y 2 z 3 x 3 y 3 z 4 x 4 y 4 z 5 x 5 y 5 z 6 x 6 y 6 z 7 x 7 y 7 z 8 x 8 …

Member Avatar
Member Avatar
+0 forum 4

I'm learning django and for the latest version of the tutorial i'm using, you must have python 3 installed. Despite the fact I have python 3 installed, python 2.7.6 is being loaded. My path originally had no reference to python, so I added it. C:\Ruby200-x64\bin;C:\Users\Freddy\AppData\Roaming\npm;C:\python33\python.exe However, python 2.7.6 is still being run even after a terminal and computer restart. I'm running Windows 7. Any ideas? EDIT: Above was my user path, my system path is as follows C:\Python33\python.exe;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\nodejs\;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\Git\bin;C:\HashiCorp\Vagrant\bin

Member Avatar
Member Avatar
+0 forum 1

Hi Friends, (i) I'm very new to python.so i wanna know which version of python is suitable for me.I have [I][B]python 2[/B][/I] and [I][B]python 3[/B][/I] in my choices..which one is best for me??? (ii)Also give me the list of GUI toolkits for respective versions.. (iii)which version has the best library for web development? Note: I will be mostly working on GUI & Web development. Thanks in advance...

Member Avatar
Member Avatar
+0 forum 7

In the parent directory O, I have a series of directories Aa, where a varies from 0-1. In each of these I have a series of directories Bb, where b varies from 0-1. In each of these there are the input/output files AaBbCc.dat and AaBbCc.out for some calculations [c also varies from 0-1]. However, due to a limit on the amount of resources I can use some of these calculations failed to complete (or even run). I have created a file 'walltime.txt' which lists the output files [AaBbCc.out] that have closed prior to the calculation finishing. It is from here …

Member Avatar
Member Avatar
+0 forum 2

I have the following directory/file setup (this is simplified): Ce +---top.txt +---X0.0 | | | +---Y0.0 | | | | | +---X0.0Y0.0Z0.0.dat | | +---X0.0Y0.0Z0.05.dat | +---Y0.05 | | | +---X0.0Y0.05Z0.0.dat | +---X0.0Y0.05Z0.05.dat +---X0.05 | +---Y0.0 | | | +---X0.0Y0.0Z0.0.dat | +---X0.0Y0.0Z0.05.dat +---Y0.05 | +---X0.0Y0.05Z0.0.dat +---X0.0Y0.05Z0.05.dat Within each Y directory, I need to make a 'psub' file, which contains appends a list of the .dat files to a copy of the file 'top.txt'. I am attempting to do this using the os.walk function in python 3: however I am incurring two problems: 1. The new psub file appears in the …

Member Avatar
Member Avatar
+0 forum 1

After reading the intresting articles of vegaseat, I finally decided to get my toes wet. So I installed Pyton 3.3.2 amd the plugin for Visual Studio 2010. The best learning is of course practice, so I started coding right away. Here is my first try: import sys print('Hello World') print('I like internet for:') for item in ['email', 'surfing', 'home']: print(item) print c=sys.stdin.read(1) This works,but if I want to eliminate the newline, auto added by the print function, nothing is printed. Google proposed, end, sep and comma, but nothing seems to work. Anyone any ideas? Thanks in advance for a solution.

Member Avatar
Member Avatar
+0 forum 8

i have a text document 'topics.txt': 1~cocoa 2~ 3~ 4~ 5~grain~wheat~corn~barley~oat~sorghum 6~veg-oil~linseed~lin-oil~soy-oil~sun-oil~soybean~oilseed~corn~sunseed~grain~sorghum~wheat 7~ 8~ 9~earn 10~acq and so on.. here the numbers correspond to the file names, i have about 20000 files. import os import re import sys sys.stdout=open('f1.txt','w') from collections import Counter from glob import glob def removegarbage(text): text=re.sub(r'\W+',' ',text) text=text.lower() return text folderpath='d:/individual-articles' counter=Counter() filepaths = glob(os.path.join(folderpath,'*.txt')) num_files = len(filepaths) with open('topics.txt','r') as filehandle: lines = filehandle.read() words = removegarbage(lines).split() counter.update(words) for word, count in counter.most_common(): probability=count//num_files print('{} {} {}'.format(word,count,probability)) i need my output to be of the form: word,count of word in topics.txt,probability, list of files,number of …

Member Avatar
Member Avatar
+0 forum 1

import os import re import sys sys.stdout=open('f1.txt','w') from collections import Counter from glob import glob def removegarbage(text): text=re.sub(r'\W+',' ',text) text=text.lower() return text folderpath='d:/induvidual-articles' counter=Counter() filepaths = glob(os.path.join(folderpath,'*.txt')) num_files = len(filepaths) with open('topics.txt','r') as filehandle: lines = filehandle.read() words = removegarbage(lines).split() counter.update(words) for word, count in counter.most_common(): probability=count//num_files print('{} {} {}'.format(word,count,probability)) i am getting a zero division error:float division by zero for the line probability=count//num_files how do i rectify it? i need my output to be of the form: word, count ,probability Plz help!

Member Avatar
Member Avatar
+0 forum 1

I'm not sure if its my computer or what. For some reason when I run programs in class they go through fine but after running the same program at home it doesnt seem to work. Basically, what I'm trying to do is create an event handler that draws a circle on the canvas each time the mouse is clicked. Also, I added a count to count the clicks and print the number of clicks. I just get an empty canvas. Ofcourse, I don't want anyone to do it for me, but can someone tell me if this program won't run …

Member Avatar
Member Avatar
+0 forum 2

The End.