-
Replied To a Post in RE.Split confussion
The strange thing is that you open the file within a loop. It means that the same file is opened repeatedly by the program. Normally you open the output file … -
Replied To a Post in RE.Split confussion
Your code is very difficult to understand. I think you can do a lot with a single regular expression, like in this example # -*- coding: utf-8 -*- """ Created … -
Replied To a Post in Asking User For Input Before Plotting Selected Points
Yes, only you need to parse the two dates and may be write a loop to catch user errors, for example from humanfriendly import parse_date, InvalidDate from datetime import datetime … -
Replied To a Post in Asking User For Input Before Plotting Selected Points
Install [humanfriendly](https://pypi.python.org/pypi/humanfriendly) from pypi (`pip install humanfriendly`), then from datetime import datetime from humanfriendly import parse_date s = raw_input('From datetime: ') dt = datetime(*parse_date(s)) print(dt) -
Replied To a Post in Plot date and time (xaxis) versus a value (yaxis) using data from txt file
I tried with the 22 data rows above. I had to replace line 36 with `plt.show()` and comment line 11. It seems to work and I don't know what you … -
Replied To a Post in Plot date and time (xaxis) versus a value (yaxis) using data from txt file
Replace line 20 by the whole block of code. -
Replied To a Post in Plot date and time (xaxis) versus a value (yaxis) using data from txt file
Use time_format = '%d/%m/%Y %H:%M' try: datetime_obj = datetime.strptime(time_string, time_format) except ValueError: print("STRING: ", repr(time_string), "FORMAT: ", repr(time_format)) raise and post the output. -
Replied To a Post in inserting zeros depending on the length
I dont see which of these programs produces the result you wrote before. It looks impossible, or perhaps there is no column PSTRIK in this new datafile. -
Replied To a Post in inserting zeros depending on the length
Can you post your code ? Are you using python 2 or 3 ? -
Replied To a Post in inserting zeros depending on the length
I don't understand the issue. Here is what python does: >>> "43".zfill(4) '0043' >>> "1394".zfill(4) '1394' >>> '123456789'.zfill(4) '123456789' -
Replied To a Post in inserting zeros depending on the length
Help on method_descriptor in str: str.zfill = zfill(...) S.zfill(width) -> string Pad a numeric string S with zeros on the left, to fill a field of the specified width. The … -
Replied To a Post in inserting zeros depending on the length
Ok, it looks like a simple ascii file with values separated by commas and windows line terminator. We can let the csv module *sniff* the dialect. The following code prints … -
Replied To a Post in inserting zeros depending on the length
The problem is that the screenshot doesn't show the info that I want: delimiter, quoting strategy, encoding. In principle you can upload the file if you zip it and use … -
Replied To a Post in inserting zeros depending on the length
The csv module has a concept of *dialect*. For example in the data shown above, I don't see separating commas or quoting characters. See for [example here](http://www.daniweb.com/software-development/python/threads/443909/learning-re-module#post1912119) how one can … -
Marked Solved Status for inserting zeros depending on the length
Hello I need to add a zero in front of a number if it is 3 or less so that it has 4 digits total. I only need this for … -
Replied To a Post in inserting zeros depending on the length
This thread is a duplicate of this one: [click here](http://www.daniweb.com/software-development/python/threads/482152/inserting-zeros-depending-on-the-length). Discussion goes on in the other thread. -
Replied To a Post in Create zip file using zipfile without zipping absolute path
Did you try oldwd = os.getcwd() os.chdir('C:/Users/UserName/Documents') try: zipdir('Folder_to_be_zipped', zipf) finally: os.chdir(oldwd) ? -
Replied To a Post in Get the mouse position on the screen on Linux.
The story goes on: there is now [PyUserInput](https://github.com/SavinaRoja/PyUserInput) which embeds pymouse and adds keyboard control too :). Install it from pypi. -
Replied To a Post in KeyPress Detection
There is also an [interesting snippet](http://www.daniweb.com/software-development/python/code/360113/tkinter-for-console-getkey-pauserestartquit) by pyTony here. -
Replied To a Post in KeyPress Detection
Here is a [tkinter example](http://www.daniweb.com/software-development/python/code/216830/tkinter-keypress-event-python) by vegaseat. -
Replied To a Post in PyEditor1.2
Are you really running *windows 95* ? I thought it died more than 15 years ago. You could perhaps rewrite the editor for python 1.5 (which was a very good … -
Replied To a Post in builtins.UnicodeDecodeError:
> builtins.UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd2 in position 14: invalid continuation byte You must use traceback and print repr of data to find exactly which conversion yields this … -
Replied To a Post in builtins.UnicodeDecodeError:
Did you check the type of `line` ? it seems to me that is a `str` (which means unicode in python 3). Again you are mixing bytes and str implicitly (`tag … -
Gave Reputation to il_doc in Big idea in Django for total novice (myself) to learn by doing...
start by learning some python on http://learnpythonthehardway.org/book/ then you'll find the [django tutorial](https://docs.djangoproject.com/en/1.6/intro/tutorial01/) VERY useful to learn how django works django documentation is amazingly written also take a look at … -
Replied To a Post in importing eyed3
An alternative to what I wrote above is to create a *per user site-packages* directory (pep 370). In my kubuntu system it means typing $ mkdir --parents ~/.local/lib/python2.7/site-packages in a … -
Gave Reputation to JasonHippy in Finding File Path
It depends on whether OpenMeetings wants the path to the tools that make up ImageMagick, or the path to the ImageMagick libraries. The ImageMagick tools (convert, identify, mogrify, composite, montage … -
Replied To a Post in Splitting a filename
> In the spirit of more than one way to do it ... Notice that python came after perl, and in python, > There should be one-- and preferably only … -
Replied To a Post in importing eyed3
Read [the paragraph](https://docs.python.org/2/tutorial/modules.html#packages) about packages in the doc first. -
Replied To a Post in importing eyed3
Try import eyeD3 To answer your second question, create for example a directory with $ mkdir ~/pymods in a terminal, then add the following lines to the file `~/.bashrc`, and … -
Replied To a Post in Is a python os possible?
One part of the question is why would we need an OS written in python ? My advice is: go linux ! -
Replied To a Post in Tuple error
As sepp2k said, create MyTime instances `t1 = MyTime(9, 59, 59)`, etc. -
Replied To a Post in python custom class return dataframe
Yes, only * There is no variable `name` in method `FileName()` * Usually, import statements are written at the beginning of the file. * Avoid `import *` as much as … -
Replied To a Post in python custom class return dataframe
Here is a short explanation about variable visibility varA = "foo" # a global variable class Bar: # Bar is another global variable varB = "baz" # a class variable … -
Replied To a Post in Accessing a Hindi Text file, counting the number of occurrences of words
You must learn to manipulate containers in python. Here is how to create the sequences from a dict similar to your counter >>> D = {'Beth': 14700, 'Jean': 13400, 'Mike': … -
Replied To a Post in Accessing a Hindi Text file, counting the number of occurrences of words
The Counter is a subclass of dict, which means that you can use it as a dictionary, or convert it to a dict with c = dict(c) You can represent … -
Replied To a Post in problem with output result to logfile
Can you post a short code with `mode = 'w'`, which doesn't rewrite the file ? -
Replied To a Post in Accessing a Hindi Text file, counting the number of occurrences of words
> But only problem is the encoding, I mean to say, the Hindi characters are not to be seen in hindi, instead Unicode Characters. It's because when you print the … -
Replied To a Post in Accessing a Hindi Text file, counting the number of occurrences of words
The best tool for this is the class `collections.Counter`. Here is an example: # -*- coding: utf-8 -*- #Python 2.7 import codecs from collections import Counter text = """ Tobacco … -
Replied To a Post in Accessing a Hindi Text file, counting the number of occurrences of words
Well, I'm using Snippsat's code with your file # -*- coding: utf-8 -*- #Python 2.7 import codecs with codecs.open('./jhij.txt', encoding='utf-8') as f: contend = f.read() word = u'इस' word_cont = … -
Replied To a Post in Accessing a Hindi Text file, counting the number of occurrences of words
Great ! -
Replied To a Post in Accessing a Hindi Text file, counting the number of occurrences of words
Sorry, without the exact file you're working on, I can't see the issue. You can attach a zipped file to a post by clicking on the paper clip icon in … -
Replied To a Post in problem with output result to logfile
Why not fh = logging.FileHandler( pjoin('specific','directory','logfile.log'), mode = 'w',) ? -
Replied To a Post in Accessing a Hindi Text file, counting the number of occurrences of words
It would help if you could zip the jhi.txt file and attach it to a post. I think you must use `u'\u0907\u0938'` and not `'\u0907\u0938'`. Notice the leading u which … -
Gave Reputation to ~s.o.s~ in Accessing a Hindi Text file, counting the number of occurrences of words
The encoding is `UTF-8`. Also as already mentioned, use the `codecs.open` function call to open and read the hindi text file. Something like: import codecs with codecs.open('hindi.txt', encoding='utf-8') as f: … -
Replied To a Post in Accessing a Hindi Text file, counting the number of occurrences of words
I think you are probably using python 2.7 where literal strings are rows of bytes and not unicode. For example, here is my console output with python 2.7 in kubuntu: … -
Replied To a Post in As a beginner, what IDE should I use?
Don't forget the beautiful [ninja IDE](http://ninja-ide.org/). -
Replied To a Post in problem with output result to logfile
> Btw, do you know how to copy users from active directory to another computer? No I don't know. It looks like a question about the windows OS rather than … -
Gave Reputation to slate in getting file from ftp or http web server
There is a script in the python distribution: pythonhome\Tools\Scripts\ftpmirror.py Maybe itt will help you if you look at it. -
Replied To a Post in problem with output result to logfile
Here is a code which woks for me import os import shutil import string import logging pjoin = os.path.join source = '/home/eric/Documents/daniweb/480781/test' # pjoin('C:', 'test') dest = '/home/eric/Documents/daniweb/480781/testing' # set … -
Replied To a Post in Accessing a Hindi Text file, counting the number of occurrences of words
The main concern is about encoding. If you know the file's encoding, you can open it with `codecs.open()` and read the file as a unicode stream. I never used a …
The End.