472,341 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,341 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 1599
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...
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...
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...
6
by: Senthil | last post by:
Code ---------------------- string Line = "\"A\",\"B\",\"C\",\"D\""; string Line2 = Line.Replace("\",\"","\"\",\"\""); string CSVColumns =...
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('...
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...
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: ...
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,...
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...
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...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

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.