how to import in python French written xls file - utf-8

I have to import in python the containt of a French written xls file.. I was managing to use the xlrd library but I'm not able to deal with the accent. I know the right codec should be UTF-8, but I don't know how to set it in the starting xls file..
any hint?

SOLVED:
in the end I decided to export the original file in csv, using the codec utf-8.

Related

How to merge Video and Subtitle on Google Colab with only specifying file path using mkvmerge?

On Google Colab I tried to create a code to merge Video and Subtitle using mkvmerge with only specifying the folder path but The code doesn't work?
##markdown <h3><b>Merge video+subtitle :</h3>
import os, sys, re
input_folder= '/content/drive/MyDrive/Videos' ##param {type:"string"}
subtitle_folder= '/content/drive/MyDrive/Videos' ##param {type:"string"}
output_folder= '/content/drive/MyDrive/Videos/NewFile' ##param {type:"string"}
from pathlib import Path
Path(output_folder).mkdir(parents=True, exist_ok=True)
for filename in os.listdir(input_folder):
inputvid = `if (filename.endswith(.mkv))`
for subname in os.listdir(subtitle_folder):
inputsub = `if (filename.endswith(.ass))`
cmd = !mkvmerge -o "$output_folder/new-{filename}.mkv" "$input_folder/{filename}" "$subtitle_folder/{subname}"
I'm noob in coding so I probably made weird mistake.😅
Could someone please help me with this code? I would appreciate your help?
EDÄ°T:
AND lets say I want to also include fonts folder in the code like fonts_folder= '/content/drive/MyDrive/fonts ` as an attachments folder how can I do this?
I found a code that does exactly what I want but it doesn't work?
https://maglit.me/mkvtoolnixcolab000foundsomewhere999

Mulesoft SFTP write .csv file encoded UTF-8 with BOM

I have the requirement to store a csv file with the SFTP write processor from Mulesoft on an SFTP server.
File format: CSV (comma as separator), UTF-8 with BOM
In a "transform message" I transform the JSON payload into application / csv encoding = "UTF-8"
That works great, the csv is then available on the SFTP server in utf-8 format.
%dw 2.0
output application/csv encoding="UTF8"
---
payload.data
My problem is how can I attach the BOM to the file?
Before you write the data to SFTP create a variable called utf8BOM using the dataweave below:
%dw 2.0
import * from dw::core::Binaries
output application/java
---
fromHex("EFBBBF")
Then create your new file using a write connector and write the variable above first: e.g. in the content put
vars.utf8BOM
Then write your content to the same file using append on the write connector.
This should output a UTF8 CSV file with the BOM bytes.

UTF-8 i18n file

I'm trying to add a Chinese localisation to a scaffolded Yesod site. I have a zh.msg message file saved as UTF-8 format using Notepad in Windows, but when I run cabal install in the project directory, I get this:
Handler\Home.hs:15:11:
Not in scope: data constructor `MsgHello'
Perhaps you meant `Msg<stderr>: hPutChar: invalid argument (invalid character)
The line in question is where I render my homepage:
$(widgetFile "homepage")
I changed both message files to be Unicode formatted instead of UTF-8, and get this message instead:
Foundation.hs:1:1:
Exception when trying to run compile-time code:
Cannot decode byte '\xff': Data.Text.Encoding.Fusion.streamUtf8: invalid UTF-8 stream
So I guess UTF-8 is the way to go... somehow.
(I'm using Notepad because I haven't set up gVim to render Unicode characters. It's apparently a bit of a feat.)
When I went to commit my changes I discovered the issue. The diff for my English file looked like this:
-Hello: Hello
+<U+FEFF>Hello: Hello
I guess notepad added the character in, and it was working its way into the Haskell code. I solved it using vim according to this answer.

Using PHPEXCEL with UTF-8 results in error messages

When I create an Excel Sheet with PHPEXCEL based on the "01simple-download-xlsx.php" example, I will get an error message in Excel as I am using UTF-8.
The error message says "Excel cannot open the file because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file." I've used the 01simple-download-xlsx.php Testfile and tried to change the $objWriter to the one out of the 26utf8.php Testfile... both didnt work...
So how can I prevent this error and create a proper UTF-8 compatible Excel file with PHPEXCEL?
The reason was:
I have saved my php files with notepad in UTF-8 format. Therefor it was saved with the UTF-8 BOM. I have reopened the files in Notepad++ and saved the files as UTF-8 Without BOM. This way the Excel file gets generated correctly.

How can I modify .xfdl files? (Update #1)

The .XFDL file extension identifies XFDL Formatted Document files. These belong to the XML-based document and template formatting standard. This format is exactly like the XML file format however, contains a level of encryption for use in secure communications.
I know how to view XFDL files using a file viewer I found here. I can also modify and save these files by doing File:Save/Save As. I'd like, however, to modify these files on the fly. Any suggestions? Is this even possible?
Update #1: I have now successfully decoded and unziped a .xfdl into an XML file which I can then edit. Now, I am looking for a way to re-encode the modified XML file back into base64-gzip (using Ruby or the command line)
If the encoding is base64 then this is the solution I've stumbled upon on the web:
"Decoding XDFL files saved with 'encoding=base64'.
Files saved with:
application/vnd.xfdl;content-encoding="base64-gzip"
are simple base64-encoded gzip files. They can be easily restored to XML by first decoding and then unzipping them. This can be done as follows on Ubuntu:
sudo apt-get install uudeview
uudeview -i yourform.xfdl
gunzip -S "" < UNKNOWN.001 > yourform-unpacked.xfdl
The first command will install uudeview, a package that can decode base64, among others. You can skip this step once it is installed.
Assuming your form is saved as 'yourform.xfdl', the uudeview command will decode the contents as 'UNKNOWN.001', since the xfdl file doesn't contain a file name. The '-i' option makes uudeview uninteractive, remove that option for more control.
The last command gunzips the decoded file into a file named 'yourform-unpacked.xfdl'.
Another possible solution - here
Side Note: Block quoted < code > doesn't work for long strings of code
The only answer I can think of right now is - read the manual for uudeview.
As much as I would like to help you, I am not an expert in this area, so you'll have to wait for someone more knowledgable to come down here and help you.
Meanwhile I can give you links to some documents that might help you:
UUDeview Home Page
Using XDFLengine
Gettting started with the XDFL Engine
Sorry if this doesn't help you.
You don't have to get out of Ruby to do this, can use the Base64 module in Ruby to encode the document like this:
irb(main):005:0> require 'base64'
=> true
irb(main):007:0> Base64.encode64("Hello World")
=> "SGVsbG8gV29ybGQ=\n"
irb(main):008:0> Base64.decode64("SGVsbG8gV29ybGQ=\n")
=> "Hello World"
And you can call gzip/gunzip using Kernel#system:
system("gzip foo.something")
system("gunzip foo.something.gz")

Resources