473,387 Members | 3,787 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,387 software developers and data experts.

split question

This is probily an easy question but I seem to be having trouble splitting on the \. I have tried """ (triple quotes) and that dosn't work, I tried '\\' but that was just guessing. my .bat file generates as
csound C:\Python24\Lib\site-packages\boa-constructor\test of snake\csd files\c.z.robertson-praleck_brome.csd

and what I need is just

csound c.z.robertson-praleck_brome.csd

The batch file just doesn't run with the entire file name
If there is a way to generate it as a shortcut instead it would be even cooler (The people that do panda3d have been able to do that)

Expand|Select|Wrap|Line Numbers
  1. def create_csd_bat(self):
  2.          "Creates a .bat file that executes a .csd file only works with windows"
  3.          dlg = wx.FileDialog(self,"load csd file", ".", "", "*.csd", wx.OPEN)
  4.          try:
  5.              if dlg.ShowModal() == wx.ID_OK:
  6.                  filename = dlg.GetPath()
  7.                  # Your code
  8.                  csdfilename = filename[:-4] 
  9.                  #linetest = '\\'
  10.                 #csdwritename = test = line.split('\\')
  11.                  outfile = open(csdfilename + '.bat', 'w')
  12.                  outfile.write('csound '+ filename)
  13.          finally:
  14.             dlg.Destroy() 
  15.  
Nov 21 '06 #1
2 1691
Never mind I found the answer to that. os.path.basename(filename)



This is probily an easy question but I seem to be having trouble splitting on the \. I have tried """ (triple quotes) and that dosn't work, I tried '\\' but that was just guessing. my .bat file generates as
csound C:\Python24\Lib\site-packages\boa-constructor\test of snake\csd files\c.z.robertson-praleck_brome.csd

and what I need is just

csound c.z.robertson-praleck_brome.csd

The batch file just doesn't run with the entire file name
If there is a way to generate it as a shortcut instead it would be even cooler (The people that do panda3d have been able to do that)

Expand|Select|Wrap|Line Numbers
  1. def create_csd_bat(self):
  2.          "Creates a .bat file that executes a .csd file only works with windows"
  3.          dlg = wx.FileDialog(self,"load csd file", ".", "", "*.csd", wx.OPEN)
  4.          try:
  5.              if dlg.ShowModal() == wx.ID_OK:
  6.                  filename = dlg.GetPath()
  7.                  # Your code
  8.                  csdfilename = filename[:-4] 
  9.                  #linetest = '\\'
  10.                 #csdwritename = test = line.split('\\')
  11.                  outfile = open(csdfilename + '.bat', 'w')
  12.                  outfile.write('csound '+ filename)
  13.          finally:
  14.             dlg.Destroy() 
  15.  
Nov 22 '06 #2
bartonc
6,596 Expert 4TB
Thanks for keeping us up-to-date. This helps us a lot.
Nov 22 '06 #3

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

Similar topics

3
by: alexk | last post by:
I've a simple question. Why the following: words = "123#@$#$@^% wordB#@$".split('~`!@#$%^&*()_+-={},./') doesn't work? The length of the result vector is 1. I'm using ActivePython 2.4 Alex
2
by: SL_McManus | last post by:
Hi All; I am fairly new to Perl. I have a file with close to 3000 lines that I would like to split out in a certain way. I would like to put the record type starting in column 1 for 2 spaces,...
3
by: rxl124 | last post by:
Hi, room Beginner of learning perl here!! I have question to all, I have below file name datebook.master which contains only 2 lines Mike wolf:12/3/44:144 park ave, paramus: 44000 Sarah kim:...
6
by: Senthil | last post by:
Code ---------------------- string Line = "\"A\",\"B\",\"C\",\"D\""; string Line2 = Line.Replace("\",\"","\"\",\"\""); string CSVColumns = Line2.Split("\",\"".ToCharArray());
3
by: John Salerno | last post by:
This is an example in the book I'm reading: string fullName = " Edward C Koop "; fullName = fullName.Trim(); string names = fullName.Split(' '); string firstName = names; //...
5
by: KC | last post by:
Can I do a split() on a string where the delimiter is one or more space characters? I have a string with spaces between the numbers but I don't know how many. You can do this easy in Perl, but...
4
by: Michele Petrazzo | last post by:
Hello ng, I don't understand why split (string split) doesn't work with the same method if I can't pass values or if I pass a whitespace value: >>> "".split() >>> "".split(" ") But into...
7
by: Matthias Winterland | last post by:
Hi, I have a simple question. When I read in a string like: a='1,2,3,4,5 6 7,3,4', can I get the list l= with a single split-call? Thx, Matthias
9
by: dtex23 | last post by:
Good afternoon all, Question about list assignment in perl... Given a piece of code that looks kinda like this for parsing some '|' delimited input text lines : ($var1, $var2, $var3) =...
1
by: John | last post by:
Hi I have written a Split function which in turn calls the standard string split function. Code is below; Function Split1(ByVal Expression As String, Optional ByVal Delimiter As String = " ",...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.