I get the following error with the this script because of the ß in filename: Weißstorch.shp. Any ideas how to solve this? Python 2.7.10
<SPAN class="comment token"># -*- coding: utf-8 -*-</SPAN>
<SPAN class="keyword token">import</SPAN> os<SPAN class="punctuation token">,</SPAN> time<SPAN class="punctuation token">,</SPAN> xlwt
<SPAN class="keyword token">import</SPAN> xlrd
<SPAN class="keyword token">from</SPAN> xlrd <SPAN class="keyword token">import</SPAN> open_workbook
myPath <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"R:\Daten\geo_daten\Arten\2015_SIC\LUBW_Weissstorch_Horststandorte"</SPAN>
SHPCounter <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN>
MyList <SPAN class="operator token">=</SPAN> list<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
Zusammengef <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"C:\temp_Geodatenverzeichnis\Nutzung.xls"</SPAN>
<SPAN class="keyword token">for</SPAN> path<SPAN class="punctuation token">,</SPAN> dirs<SPAN class="punctuation token">,</SPAN> files <SPAN class="keyword token">in</SPAN> os<SPAN class="punctuation token">.</SPAN>walk<SPAN class="punctuation token">(</SPAN>myPath<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> file <SPAN class="keyword token">in</SPAN> files<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">if</SPAN> file<SPAN class="punctuation token">.</SPAN>lower<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>endswith<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'.shp'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN> path <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\"</SPAN> <SPAN class="operator token">+</SPAN> file
SHPCounter <SPAN class="operator token">+=</SPAN> <SPAN class="number token">1</SPAN>
<SPAN class="keyword token">print</SPAN> SHPCounter
accessTime <SPAN class="operator token">=</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>getatime<SPAN class="punctuation token">(</SPAN>os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>join<SPAN class="punctuation token">(</SPAN>path<SPAN class="punctuation token">,</SPAN> file<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># last access time</SPAN>
actualTime <SPAN class="operator token">=</SPAN> time<SPAN class="punctuation token">.</SPAN>time<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
MyList<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>path <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\"</SPAN> <SPAN class="operator token">+</SPAN> file <SPAN class="operator token">+</SPAN> <SPAN class="string token">"___"</SPAN> <SPAN class="operator token">+</SPAN> file <SPAN class="operator token">+</SPAN> <SPAN class="string token">"___"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"""{}
"""</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>int<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN>actualTime <SPAN class="operator token">-</SPAN> accessTime<SPAN class="punctuation token">)</SPAN><SPAN class="operator token">/</SPAN><SPAN class="number token">3600</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Write in excel</SPAN>
data <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">for</SPAN> line <SPAN class="keyword token">in</SPAN> MyList<SPAN class="punctuation token">:</SPAN>
data<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN>word <SPAN class="keyword token">for</SPAN> word <SPAN class="keyword token">in</SPAN> line<SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"___"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> word<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> data
wb <SPAN class="operator token">=</SPAN> xlwt<SPAN class="punctuation token">.</SPAN>Workbook<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
sheet <SPAN class="operator token">=</SPAN> wb<SPAN class="punctuation token">.</SPAN>add_sheet<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"NichtGenutzt"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> row_index <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN>len<SPAN class="punctuation token">(</SPAN>data<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> col_index <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN>len<SPAN class="punctuation token">(</SPAN>data<SPAN class="punctuation token">[</SPAN>row_index<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
sheet<SPAN class="punctuation token">.</SPAN>write<SPAN class="punctuation token">(</SPAN>row_index<SPAN class="punctuation token">,</SPAN> col_index<SPAN class="punctuation token">,</SPAN> data<SPAN class="punctuation token">[</SPAN>row_index<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN>col_index<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
wb<SPAN class="punctuation token">.</SPAN>save<SPAN class="punctuation token">(</SPAN>Zusammengef<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Error Message and print statements:
R:\Daten\geo_daten\Arten\2015_SIC\LUBW_Weissstorch_Horststandorte\LUBW_Weißstorch_Horststandorte_E.shp
1
[['R:\\Daten\\geo_daten\\Arten\\2015_SIC\\LUBW_Weissstorch_Horststandorte\\LUBW_Wei\xdfstorch_Horststandorte_E.shp', 'LUBW_Wei\xdfstorch_Horststandorte_E.shp', '1551\n ']]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xdf in position 74: ordinal not in range(128)