Beat_Slayer 17 Posting Pro in Training

You must provide full path to the dtsx file I believe.

import os

PACKAGENAME = 'something'
os.system(r'C:\\dtexec /f "c:\\folder\\%s.dtsx"' % PACKAGENAME)
Beat_Slayer 17 Posting Pro in Training

The 'r' stands for raw, so the string is interpreted as it is, otherwise it must be:

import os

os.system(r'C:\\dtexec /f "PACKAGENAME.dtsx"')

because of the backslash interpreted as a escape.

You can also do:

import os

PACKAGENAME = 'something'
os.system(r'C:\\dtexec /f "%s.dtsx"' % PACKAGENAME)
Beat_Slayer 17 Posting Pro in Training
import os

os.system(r'C:\dtexec /f "PACKAGENAME.dtsx"')

Cheers and Happy codding

Beat_Slayer 17 Posting Pro in Training

I believe the problem relys on input file.

It works here with the sample file you provided.

Can you provide more data and info.

Cheers

Beat_Slayer 17 Posting Pro in Training

I got it. LOL Pretty easy also. :)

Because you should be doing a 'cur.prepare' and not an 'cur.execute'.

Execute for actions on the table, prepare for visualization.

Beat_Slayer 17 Posting Pro in Training

I don't get it.

Something weird. :D

Can you post the db.

Beat_Slayer 17 Posting Pro in Training

Can you post as file or PM it to me, it's a litle messy to copy.

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

Can you provide a sample file.

Your sample doesn't even have the GE.

I changed the second BS tag to GE.

f_in = open('blocks.txt').read()
f_out = open('output.csv', 'w')
f_out.write('AC\tID\tFA\tOS\tSF\tBS\tGE\n')

blocks = [x for x in f_in.split('//') if x]
for item in blocks:
    infos = [x for x in item.split('\n') if x and x != 'XX']
    for field in infos:
        if field.startswith('AC'):
            f_out.write('%s\t' % field[3:])
        elif field.startswith('ID'):
            f_out.write('%s\t' % field[3:])
        elif field.startswith('FA'):
            f_out.write('%s\t' % field[3:])
        elif field.startswith('OS'):
            f_out.write('%s\t' % field[3:])
        elif field.startswith('SF'):
            f_out.write('%s\t' % field[3:])
        elif field.startswith('BS'):
            f_out.write('%s\t' % field[3:])
        elif field.startswith('GE'):
            f_out.write('%s\t\n' % field[3:])

f_out.close()
Beat_Slayer 17 Posting Pro in Training

Well you need Pyserial or USPP if you connect through the COM port.

And from there on, more info is needed.

Happy coding

Beat_Slayer 17 Posting Pro in Training

One question.

When the player looses, how are you saving the highscore?

In your example you show a player that played and then you call the highscore from the menu.

Beat_Slayer 17 Posting Pro in Training

There are no aditional modules there.

You can even use the cElementTree module also included on python.

Beat_Slayer 17 Posting Pro in Training

lol

How about some search?

I've written something easilly adjustable for some user something like one week ago.


Finding string instance in file - replace bytes after it

Beat_Slayer 17 Posting Pro in Training

Thats not complicated. If there is a fixed code lenght you can call them like:

codeA, codeB = CAcodes.split(' ')

and eliminate the for's.

EDIT: I'll read your code when I return.

Beat_Slayer 17 Posting Pro in Training

What I mean by taking out the breaks, was to design the code in other way without that logical path.

Beat_Slayer 17 Posting Pro in Training

I'm sorry but I'm going to redirect you. lol

I believe this is the right point to redirect you.

Beat_Slayer 17 Posting Pro in Training

This is what I've been trying to work with, but it just keeps printing out whatever is on the file.

def highscore():
    newScore = sum(points)
    print
    openHigh = open("highScore.txt", 'r')
    highScore = openHigh.read()
    print highScore
    print newScore

    if newScore > highScore:
        openHigh.write(newScore)
        openHigh.close()
        print highScore

You have the file open as reading mode. Thats why.

openHigh = open("highScore.txt", [B]'r'[/B])
Beat_Slayer 17 Posting Pro in Training

The breaks are your problem. Try to take them out.

Happy coding...

Beat_Slayer 17 Posting Pro in Training

Here.

score.txt content before:

Jane-60
f_score = open ('score.txt')
old_highscore = f_score.readlines()[0]
f_score.close()
old_name, old_score = old_highscore.split('-')
name = 'Joe'
score = 80
print old_name, old_score
if score > int(old_score):
    print name, score
    f_score = open ('score.txt', 'w')
    f_score.write('%s-%s' % (name, score))
    f_score.close()

score.txt content after:

Joe-80
Beat_Slayer 17 Posting Pro in Training

See my example.

Write the name and the socre with some separator.

Then do some spliting on reading, and compare only the last field.

Beat_Slayer 17 Posting Pro in Training

And the code?

I can't see it. lol

:)

f_score = open ('score.txt')
old_score = int(f_score.readlines()[0])
f_score.close()
score = 80
print old_score
if score > old_score:
    f_score = open ('score.txt', 'w')
    f_score.write('%s' % score)
    f_score.close()
Beat_Slayer 17 Posting Pro in Training

Here it is.

import warnings

def maxgen(fname, worksheet=1,encoding='cp1251'):
    warnings.filterwarnings('ignore')
    from pyExcelerator import *
    warnings.filterwarnings('always')

Happy coding...

Beat_Slayer 17 Posting Pro in Training

Maybe a sample file and some info would help mate.

I'm just trying to help, but I have litle insight on this.

And this?

Beat_Slayer 17 Posting Pro in Training

I believe I have something for you.

Parsing Simulink mdl files with Pyparsing

Maybe you can adapt or reuse some of the code, or at least get a base to start with.

Beat_Slayer 17 Posting Pro in Training

Gribouillis said it all.

There is no reason for repeating code when it can be reused.

Beat_Slayer 17 Posting Pro in Training

I saw your scripts just now.

So what do you want?

You searching for a way of importing MDL0? Right?

Beat_Slayer 17 Posting Pro in Training

You need to start here, so you can load those collada files and work with them.

Beat_Slayer 17 Posting Pro in Training

So you can't read C++, and want to convert some C++ files to Python?

How about leaking the C++ files so we can help you?

Meanwhile, i'll google for tools. ;)

Beat_Slayer 17 Posting Pro in Training

How about this?

class Word_Counter():

    def __init__(self):
        self.count = {}

    def add_string(self, s):
        word_list = s.split(' ')
        self.add_list(word_list)

    def add_list(self, wl):
        for item in wl:
            if self.count.has_key(item):
                self.count[item] += 1
            else:
                self.count[item] = 1

    def add_mapper(self, ml):
        for item in ml:
            if self.count.has_key(item[0]):
                self.count[item[0]] += item[1]
            else:
                self.count[item[0]] = item[1]
    


str1 = 'the quick brown fox jumps over the lazy dog'

d = Word_Counter()

d.add_string(str1)

print d.count

"""
{'brown': 1, 'lazy': 1, 'over': 1, 'fox': 1, 'dog': 1, 'quick': 1, 'the': 2, 'jumps': 1}
"""

list1 = ('the', 'quick', 'blue', 'cat', 'jumps', 'over', 'the', 'lazy', 'turtle') 

d.add_list(list1)

print d.count

"""
{'blue': 1, 'brown': 1, 'lazy': 2, 'turtle': 1, 'over': 2, 'fox': 1, 'dog': 1, 'cat': 1, 'quick': 2, 'the': 4, 'jumps': 2}
"""

map1 = [('the', 1), ('quick', 1), ('brown', 1), ('fox', 1), ('jumped', 1), ('over', 1), ('the', 1), ('lazy', 1), ('grey', 1), ('dogs', 1)]

d.add_mapper(map1)

print d.count

"""
{'blue': 1, 'brown': 2, 'lazy': 3, 'turtle': 1, 'grey': 1, 'jumped': 1, 'over': 3, 'fox': 2, 'dog': 1, 'cat': 1, 'dogs': 1, 'quick': 3, 'the': 6, 'jumps': 2}
"""
Beat_Slayer 17 Posting Pro in Training

I think this should give some insight, if I'm understanding what you are trying to do.

def merge_dic(merged_dic, wordlist):
    for item in wordlist:
        if merged_dic.has_key(item):
            merged_dic[item] += 1
        else:
            merged_dic[item] = 1

file1 = 'this is a dummy sample file for example as sample'
file2 = 'this is another dummy sample file also created for example with \
some samples repeated for example'

list1 = file1.split(' ')
list2 = file2.split(' ')

all_count = {}
file_lists = []
file_lists.extend(list1)
file_lists.extend(list2)

merge_dic(all_count, file_lists)

print 'all_count =', all_count

file_uniques = {}
file_lists = []                 # Converting lists to sets it's the fastest and
file_lists.extend(set(list1))   # simplest way that I know of eliminating
file_lists.extend(set(list2))   # duplicates on a list, when position doesn't mather

merge_dic(file_uniques, file_lists)

print 'file_uniques =', file_uniques

Happy coding!

Beat_Slayer 17 Posting Pro in Training

It can be just me, but it seems something is wrong!

Can you explain a little further.

You want to know the words that exist in the two files, is that it?

Or do you want to count the ocurrences in each file?

Beat_Slayer 17 Posting Pro in Training

Your welcome.

Happy to help!

You can close the thread marking it as solved.

Cheers, and happy coding!!!

Beat_Slayer 17 Posting Pro in Training
f = open('filename.rc')
old_rc = f.readlines()
f.close()

host = 'PARTYHOST'
new_ip = '127.0.0.1'
f = open('filename.rc', 'w')
for i in range(len(old_rc)):
    if old_rc[i].find(host) != -1:
        f.write('%s %s\n' % (host, new_ip)) #You should check the newline
    else:
        f.write(old_rc[i])
f.close()
Beat_Slayer 17 Posting Pro in Training

Like this?

if(empty($veh_img) AND empty($disk_img)){
    $galpic="image.gif";
}else{
    $galpic="$disk_img";
}
Beat_Slayer 17 Posting Pro in Training
if(!strcmp($row['dtFirstContactSt'], '0000-00-00') AND !strcmp($row['dtMarketingSt'], '0000-00-00')) {
echo "<td width='156'>" . "&nbsp </td>";
} else {
echo "<td bgcolor=FF0000 width='156'>" .$row['dtFirstContactSt']. "</td>";
}
Beat_Slayer 17 Posting Pro in Training

I guess it is

windowSurface.blit(pi, 25, 25)

or

windowSurface.blit(pi, (25, 25))

but i never used pygame.

Beat_Slayer 17 Posting Pro in Training

Click on "Start", select "Run" and type "command"!

Beat_Slayer 17 Posting Pro in Training

Have you tried like this?

r = csv.reader(open('v20100515.csv', 'rb'))

EDIT: Sorry i began the reply and went eat some sandwich, finnished when I came, and there were already all this ones posted, but I didn't saw them.

Beat_Slayer 17 Posting Pro in Training

Example command for a script file 'protein.py' in directory 'D:\scripts\protein\', the executable file will be created in 'D:\scripts\protein\exe'.

cxfreeze d:\scripts\protein\protein.py --target-dir d:\scripts\protein\exe

Demonstration on Windows XP with Python 2.6.

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Beat_Slayer>cd c:\python26\scripts

C:\Python26\Scripts>cxfreeze d:\scripts\protein\protein.py --target-dir d:\scripts\protein\exe
creating directory d:\scripts\protein\exe
copying C:\Python26\lib\site-packages\cx_Freeze\bases\Console.exe -> d:\scripts\protein\exe\protein.exe
copying C:\WINDOWS\system32\python26.dll -> d:\scripts\protein\exe\python26.dll
writing zip file d:\scripts\protein\exe\protein.exe

  Name                      File
  ----                      ----
m StringIO
m UserDict
m __builtin__
m __future__
m __main__                  d:\scripts\protein\protein.py
m _abcoll
m _bisect
m _codecs
m _codecs_cn
m _codecs_hk
m _codecs_iso2022
m _codecs_jp
m _codecs_kr
m _codecs_tw
m _collections
m _functools
m _heapq
m _locale
m _multibytecodec
m _random
m _sre
m _strptime
m _struct
m _subprocess
m _threading_local
m _warnings
m abc
m array
m base64
m bdb
m binascii
m bisect
m bz2                       C:\Python26\DLLs\bz2.pyd
m cPickle
m cStringIO
m calendar
m cmd
m codecs
m collections
m copy
m copy_reg
m cx_Freeze__init__         C:\Python26\lib\site-packages\cx_Freeze\initscripts\
Console.py
m datetime
m difflib
m dis
m doctest
m dummy_thread
P encodings
m encodings.aliases
m encodings.ascii
m encodings.base64_codec
m encodings.big5
m encodings.big5hkscs
m encodings.bz2_codec
m encodings.charmap
m encodings.cp037
m encodings.cp1006
m encodings.cp1026
m encodings.cp1140
m encodings.cp1250
m encodings.cp1251
m encodings.cp1252
m encodings.cp1253
m encodings.cp1254
m encodings.cp1255
m encodings.cp1256
m encodings.cp1257
m encodings.cp1258
m encodings.cp424
m encodings.cp437
m encodings.cp500
m encodings.cp737
m encodings.cp775
m encodings.cp850
m encodings.cp852
m encodings.cp855
m encodings.cp856
m encodings.cp857
m encodings.cp860
m encodings.cp861
m encodings.cp862
m encodings.cp863
m encodings.cp864
m encodings.cp865
m encodings.cp866
m encodings.cp869
m encodings.cp874
m encodings.cp875 …
Beat_Slayer 17 Posting Pro in Training

I think your line 28 should have the login address page, and not the page you are trying to read later.

Beat_Slayer 17 Posting Pro in Training

Do a litle search on the forum, theres a lot of CSV search and modify examples.

Write a tryout, and post the results, with input files and desired output.

Happy coding

Beat_Slayer 17 Posting Pro in Training

The concept is the same as in this Tech B snippet.

Give it a try,

Happy coding.

Beat_Slayer 17 Posting Pro in Training

Don't make the things more difficult.

1 - install cx_freeze.

2 - Open windows command shell, and navigate to your python install dir, then to scripts inside that dir.

3 - Type cxfreeze plus your path and script name, something like this:

cxfreeze d:\scripts\hello.py

4 - It will create a dir called dist with the files ready.

And you are done.

No need to do a setup script, or any modification to your script.

Beat_Slayer 17 Posting Pro in Training

The working file, is the file wich you are processing.

The one that you create or open, and read or write to it.

Beat_Slayer 17 Posting Pro in Training

For your example you open python command-line and type.

cxfreeze hello.py --target-dir dist

as it is on the documentation, your hello.py its a normal python script, without no imports or references to cx_freeze.

Beat_Slayer 17 Posting Pro in Training

Assuming you have a script called hello.py which you want to turn into an executable, this can be accomplished by this command:

cxfreeze hello.py --target-dir dist

Source

You must run the cx_freeze script to modify your script, you don't include or import cx_freeze on your scripts.

The info you misunderstood, is to make distutils setup scripts with cx_freeze.

Beat_Slayer 17 Posting Pro in Training
Beat_Slayer 17 Posting Pro in Training
Beat_Slayer 17 Posting Pro in Training

Something like this can do it also:

overwrite = None

print w.fill('WIP will create Backup, Resized and Watermarked folders to store the original, resized and watermarked pictures. It will overwrite them if they already exists. Are you sure you want to continue (y/n)?')
While overwrite.lower() != 'n' and overwrite.lower() != 'y':
    overwrite = raw_input('> ')
if overwrite == 'y':
    #Create a Backup directory
    if not os.path.exists('Backup'):
        os.mkdir('Backup')
    
    #Create a Resized directory
    if not os.path.exists('Resized'):
        os.mkdir('Resized')
    
    #Create a marked directory
    if not os.path.exists('Watermarked'):
        os.mkdir('Watermarked')
elif overwrite == 'n':
    print 'Thank you for using WIP'
    sys.exit()
Beat_Slayer 17 Posting Pro in Training

Thanks for the words tonyjv.

And btw, I have no solution posted on mastermind.

Beat_Slayer 17 Posting Pro in Training

I'm sorry if you take it personnaly vegaseat, I really didn't mean it.

I just see lost of my posts harshly commented, and decided to let it out, only that.

Congrats