473,503 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

os.path and manipulating the records within the list

1 New Member
I have around 100 ASCII files in a folder. I will apply some processing on each ASCII file and save them as raster files.
In order to work with each ASCII file I have created the following access:
workspace = "C:\\ASCII\\1950"
foldername = join(workspace,'*.asc')
AsciiFiles = glob.glob(foldername)

The result is a list like :
[‘'C: \\1950-1.asc', 'C: \\1950-2.asc', 'C\1950-3.asc']
I would like to create a new list which will include the path and file name of the outputs, and that list should look like this
[‘'C: \\1950-1.tiff, 'C: \\1950-2.tiff', 'C\\1950-3.tiff']
Thank you for your help.
Dec 8 '10 #1
3 1698
dwblas
626 Recognized Expert Contributor
Look at string.replace and replace ".asc" with ".tiff".
Dec 8 '10 #2
Joshua Brooks
3 New Member
This is not the only way, but I had a similiar situation and this is how I solved it. It iterates through the list of files, chops the last three digits off, and adds 'tiff'. Then it adds that to a new list.

Expand|Select|Wrap|Line Numbers
  1. asclist = ['C: \\1950-1.asc', 'C: \\1950-2.asc', 'C\\1950-3.asc']
  2. tifflist=[]
  3. for asc_file in asclist:
  4.     tifflist.append(asc_file[:-3]+'tiff')
  5.  
Dec 8 '10 #3
dwblas
626 Recognized Expert Contributor
I always use the dot, ".asc", [:-4], in my paranoid world when replacing, globbing, etc. because it eliminates files that end with just asc.
Dec 9 '10 #4

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

Similar topics

12
5212
by: Kin®sole | last post by:
Hi I'm very new to VB (using VB6) I have two lists one blank and one containing names in the format of surname and then forename.I also have a combo box containing forenames.When I select a...
29
4310
by: Scott Marquardt | last post by:
Consider a table that holds Internet browsing history for users/machines, date/timed to the minute. The object is to tag all times that are separated by previous and subsequent times by x number of...
4
1857
by: jean.ockert | last post by:
Greetings. Access version 2003 on an XP system I am using the template "Event Management" database as the primary database and need additional functionality added. I have a dance studio. ...
2
1342
by: Lee-Anne Waters via AccessMonster.com | last post by:
Hi, would someone please help me with this problem. i have a list box that displays a persons various sub records. what i want to do is to be able to double click a list box record and have it...
1
1168
by: Jean Christophe Avard | last post by:
Hi! I am designing an application, and I need some pointers. I have a database that has 5 tables: a table "Items" and 4 other table that has relationship to "Item". I have to retreive all the...
3
9809
by: funkyj | last post by:
I want to call os.path.join() on a list instead of a variable list of arguments. I.e. (186:0)$ python iPython 2.4 (#2, Feb 18 2005, 16:39:27) ] on freebsd4 Type "help", "copyright",...
1
1307
by: tehxd | last post by:
I having a table something like this: startdate | stime | endate | etime | tool 3/3/07 | 8:47 | 3/4/07 | 00:30 | A 3/4/07 | 3:57 | 3/4/07 | 4:30 | B 3/4/07 | 8:21 | ...
5
2878
by: megahurtz | last post by:
I need to put together an SQL statement and I can't think of how to make it work properly. The scenario is that I have news items in a database that have a launch time and can optionally have an...
4
916
by: Ben Keshet | last post by:
Emile van Sebille wrote: ....wrong. I thought I should omit the comma and didn't put it. I guess that stating the obvious should be the first attempt with beginners like me. Thanks for thinking...
1
4175
by: colintis | last post by:
Hi guys, I'm actually doing this from Access, which requires to connect to an excel worksheet, then calculate the average number of that day within a specific time. For testing purpose I put the...
0
7203
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
7087
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
7334
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...
1
6993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5579
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
1
737
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
383
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.