i have a csv file i wanna split. how can I split the degree, minutes and second coordinates in column(lat) and (long) into multiple columns in such a way that, all degrees(°) under lat will be in a column, all minutes(') under lat will be in another column while all sec(") under lat will be in another column. Same goes for (long).then remove the (°,',")from the result and be left with splited number And i finnally want to save result as new .csv file. How can I achieve this with python.And The code down there could not work. i don't get how i can do that.
lat long
5°78'45" 7°45'21.4"
5°12'45" 7°55'54.4"
7°56'56.5" 5°8'56"
import pandas as pd
import csv
import xlrd
name= "COORD.csv"
df=pd.read_csv(name)
print(df)
for row in pd.read_csv(name):
list= [(row.split(",")[0]) for row in name]
Traceback (most recent call last):
File "pandas\_libs\parsers.pyx", line 1149, in
pandas._libs.parsers.TextReader._convert_tokens
File "pandas\_libs\parsers.pyx", line 1279, in
pandas._libs.parsers.TextReader._convert_with_dtype
File "pandas\_libs\parsers.pyx", line 1295, in
pandas._libs.parsers.TextReader._string_convert
File "pandas\_libs\parsers.pyx", line 1518, in
pandas._libs.parsers._string_box_utf8
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 1:
invalid start byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/Temmy/.PyCharmEdu2019.1/config/scratches/crawl.py", line 5, in
<module>
df=pd.read_csv(name)
File "C:\Users\Temmy\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\pandas\io\parsers.py", line 685, in parser_f
return _read(filepath_or_buffer, kwds)
File "C:\Users\Temmy\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\pandas\io\parsers.py", line 463, in _read
data = parser.read(nrows)
File "C:\Users\Temmy\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\pandas\io\parsers.py", line 1154, in read
ret = self._engine.read(nrows)
File "C:\Users\Temmy\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\pandas\io\parsers.py", line 2048, in read
data = self._reader.read(nrows)
File "pandas\_libs\parsers.pyx", line 879, in
pandas._libs.parsers.TextReader.read
File "pandas\_libs\parsers.pyx", line 894, in
pandas._libs.parsers.TextReader._read_low_memory
File "pandas\_libs\parsers.pyx", line 971, in
pandas._libs.parsers.TextReader._read_rows
File "pandas\_libs\parsers.pyx", line 1103, in
pandas._libs.parsers.TextReader._convert_column_data
File "pandas\_libs\parsers.pyx", line 1156, in
pandas._libs.parsers.TextReader._convert_tokens
File "pandas\_libs\parsers.pyx", line 1279, in
pandas._libs.parsers.TextReader._convert_with_dtype
File "pandas\_libs\parsers.pyx", line 1295, in
pandas._libs.parsers.TextReader._string_convert
File "pandas\_libs\parsers.pyx", line 1518, in
pandas._libs.parsers._string_box_utf8
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 1:
invalid start byte