Renaming/Renumbering any list item in QuickBooks will affect both historical and future transactions.
QuickBooks will not “retain” the fact that it once had a different number and/or name.
Says Laura on this forum.
My searches for this:
- quickbooks rename items
-
what is the effect of renaming items in Quickbooks
- quickbooks rename items effects
Tags: QuickBooks, Items, Editing
Posted by Greg Pinero (Primary Searcher) as QuickBooks at 11:36 AM MST
Comments Off
This thread finally pointed out the fact that Mark Hammond’s Python for Windows extensions includes a demonstration of killing processes on Windows:
On my PC:
C:\Python24\Lib\site-packages\win32\scripts\killProcName.py
Keep in mind when using this that you should leave the .exe off of process names, and the process names are case sensitive.
My searches on this:
- python kill a process
- python XP find PID of a process
- win32api.TerminateProcess
- python XP kill process by name
Tags: python, win32, processes, kill, thread
Posted by Greg Pinero (Primary Searcher) as win32, Python at 12:35 PM MST
Comments Off
Update: Here’s the best way:
download and install the python-dateutil package from http://labix.org/python-dateutil
From the examples on the page here’s the code you would use:
import datetime
from dateutil.relativedelta import relativedelta
NOW = datetime.datetime.now()
NOW + relativedelta(months=+1)
Below is my old, home-brewed method (does seem to work):
You’ll need the mxDateTime module to run it.
import datetime
import mx.DateTime
from math import ceil
def monthify(anint):
if anint%12==0:return 12
else:return anint%12
def add_months_to_date(base_date,number_months):
"""Note: if day in base_date is > highest day in new month
then day become highest day in new month.
base_date can be a datetime.date,datetime.datetime,
or mx.DateTime.Date. We return datetime.datetime"""
base_date=mx.DateTime.Date(base_date.year,base_date.month,base_date.day)
#calculate what year it will be
years_to_add=ceil(
float((number_months-(12-base_date.month)))/float(12))
newyear=base_date.year+max(years_to_add,0)
#calculate new month
newmonth=monthify(base_date.month+number_months)
#calculate new day
max_day=mx.DateTime.Date(newyear,newmonth,1).days_in_month
newday=min(base_date.day,max_day)
#finish up
#new_date=mx.DateTime.Date(newyear,newmonth,newday)
new_date=datetime.datetime(newyear,newmonth,newday)
return new_date
if __name__=="__main__":
#some testing
print add_months_to_date(datetime.date(1999,12,31),2)
print add_months_to_date(datetime.date(1999,12,1),1)
print add_months_to_date(datetime.date(1999,12,1),31)
print add_months_to_date(datetime.datetime(2020,1,1),4)
print add_months_to_date(datetime.datetime(2005,5,3),1)
print add_months_to_date(datetime.datetime(2006,7,27),15)
Update
I have now created this online date calculator to let you add months to a date and more. You can also view its Python source code to see how it works.
Posted by Greg Pinero (Primary Searcher) as Python at 5:09 PM MST
4 Comments »
Question: How can I capture all of my print statements to a file, but still have them shown in the console?
Answer: Read on!
Here’s a little script I put in a file called “Logger.py”.
"""
Capture print statments and write them to a log file
but still allow them to be printed on the screen.
Usage: see if __name__=='__main__': section below.
"""
import sys
import time
class Logger:
def __init__(self, stdout, filename):
self.stdout = stdout
self.logfile = file(filename, 'a')
self.logfile.write('nnNew run at %snn' % time.ctime())
def write(self, text):
self.stdout.write(text)
self.logfile.write(text)
self.logfile.flush()
def close(self):
"""Does this work or not?"""
self.stdout.close()
self.logfile.close()
if __name__=='__main__':
#Usage:
logger = Logger(sys.stdout, 'log.txt')
sys.stdout = logger
print 'this should go on screen and in file'
print 'this too'
print
Then to use this, I just put this mess of statements below in my “if __name__==’__main__’” section of each script*. Then every script I run has its console messages nicely saved to a file for me.
import Logger;logger=Logger.Logger(sys.stdout,'log.txt');sys.stdout=logger
Big thanks to the folks on this thread for suggesting this code.
*Best to not put that mess of statements at the top of your script because you’ll get some weird results if another module imports it.
Tags: python, logging, stdout, logfile
Posted by Greg Pinero (Primary Searcher) as Python at 9:00 AM MST
Comments Off
Let’s say I have a module named “Excellent Module.py”
How would I import that into a script since:
import Excellent Module
doesn’t work?
Answer, use:
ExcellentModule = __import__('Excellent Module')
Thanks Farshid.
Posted by Greg Pinero (Primary Searcher) as Uncategorized, Python at 9:00 PM MST
2 Comments »