error: failed to encode '---------_dict.sql' from UTF-8 to Windows-1250 - sql

when I download the repository I get this error from the git
error: failed to encode '---------_dict.sql' from UTF-8 to Windows-1250.
Then while I want to commit and push I get the same error with the same files with the .sql extension. Anyone have any idea? Someone had a similar problem? Could it be related to the .gitattributes file which has
* .sql text working-tree-encoding = Windows-1250

This error message means that some part of the conversion failed, most likely because the contents of the file cannot be converted to windows-1250. It's likely that the file contains UTF-8 sequences corresponding to Unicode characters that have no representation in windows-1250.
You should contact the author of the repository and notify them of this problem and ask them to fix it. In your local system, you can add .git/info/attributes which has the following to force the files to UTF-8 instead:
*.sql text working-tree-encoding=UTF-8
Note that if you do this, you must ensure that the files you check in are actually UTF-8 and not windows-1250.

Related

I am getting the error message "ERROR: invalid byte sequence for encoding "WIN1251": 0x00"

I am trying to load the CSV to my postgres database but I am getting the above error message:
My query is :
COPY dbo.tbl(col1,col2)
FROM 'C:\Data\dbo.tbl.csv' DELIMITER ',' null as 'null' encoding 'windows-1251' CSV;
I tried this link for reference:https://www.postgresqltutorial.com/import-csv-file-into-posgresql-table/'
Can someone please help me what is the issue. I am new to postgres database.
For my experience, I have csv file with encoding 'WIN874' and postgres client encoding is 'UTF-8'. I can use copy command without problems.
To make sure that your file encoding is 'WIN1251', you can open your csv file in visual studio code. It will show file encoding on the right bottom pane.

UTF-8 encoding for .sql files created or modified in SSMS

The default encoding for files saved by my SSMS (v18) is ASCII, not UTF-8.
I’ve tried the steps below to set the default encoding to UTF-8 (so that I wouldn’t have to remember to set it every time I create/modify a file), but the default encoding remains ASCII.
Outside of SSMS, I can change the encoding in a text editor, but I don’t want to have to do that every time.
Have you encountered this issue and, if so, how did you resolve it?
Steps I tried:
From within SSMS, open the “template” file: C:\Program Files
(x86)\Microsoft SQL
Server\120\Tools\Binn\ManagementStudio\SqlWorkbenchProjectItems\Sql\SQLFile.sql.
Re-save using correct encoding:
File => Save As
Click the arrow next to the Save button
Choose the relevant encoding: Unicode (UTF-8 with asignature) - Codepage 65001
This is supposed to result in all new query windows having UTF-8 as the default encoding. But, this doesn’t work for me.

Boto3: upload file from base64 to S3

How can I directly upload a base64 encoded file to S3 with boto3?
object = s3.Object(BUCKET_NAME,email+"/"+save_name)
object.put(Body=base64.b64decode(file))
I tried to upload the base64 encoded file like this, but then the file is broken. Directly uploading the string without the base64 decoding also doesn't work.
Is there anything similar to set_contents_from_string() from boto2?
I just fixed the problem and found out that the way of uploading was correct, but the base64 string was incorrect because it still contained the prefix data:image/jpeg;base64, - removing that prefix solved the problem.
If you read the documentation thoughtfully on Object.put, you will see this
response = object.put(
ACL='private'......,
Body=b'bytes'|file,
.....,
Body only accept file object or bytes, any other type will failed. base64.b64decode doesn't read file object automatically, you must read the data into the decode module.
# FIX
object.put(Body=base64.b64decode(file.read()))
As reminder, always post the stacktrace.

How can I determine if a file upload is a valid CSV file - or at least text - in ColdFusion 8?

I have a form which allows a user to upload a file to the server. How can I validate that the uploaded file is in fact the expected format (CSV, or at least validate that it is a text file) in ColdFusion 8?
For simple formats like CSV, just check yourself, for example via regex.
<cffile action="read" file="#uploadedFile#" variable="contents" charset="UTF-8">
<cfset LooksLikeCSV = REFind("^([^;]*;)+[^;]*$", contents)>
You can place additional checks with regard to file size limits or forbidden characters.
For other file formats, you can check for header signatures that occur in the first few bytes of the file.
You could even write a full parser for your expected file format - for CSV validation, you could do a ListToArray() at CR/LF and check each line individually against a regex. XML should work pretty straightforward as well - just try to pass it to XmlParse(). Binary formats like images are a little more difficult, but libraries exist there as well.
I dont know if it can help you but Ben Nadel wrote excellents posts about CSV:
http://www.bennadel.com/blog/483-Parsing-CSV-Data-Using-ColdFusion.htm
http://www.bennadel.com/blog/976-Regular-Expressions-Make-CSV-Parsing-In-ColdFusion-So-Much-Easier-And-Faster-.htm
http://www.bennadel.com/blog/501-Parsing-CSV-Values-In-To-A-ColdFusion-Query.htm
I think it's as simple as specifying the accept value in cffile ...Unfortunately the CF8 docs don't specify the value as part of the info for cffile ... It's under file management ...
<cffile action=”upload” filefield=”filename” destination=”#destination#” accept=”text/csv”>
CF8 » Controlling the type of file uploaded

Pig problem with load file with complicated name

i need to load file in pig which has a long and complicated name:
dealnews-2011-04-01T12:00:00:00.211-02:00.csv
Pig complained:
ERROR org.apache.pig.tools.grunt.Grunt - ERROR 2999: Unexpected internal error. java.net.URISyntaxException: Relative path in absolute URI:
anyone knows what's the problem? Thanks.
If it's forming a URI from that, the : is a reserved character.
Think about it: file://a:b ... this would be taken as an FTP login.
Your error message seems to complain that what's left after the string is parsed is a relative path (I guess 00.csv after the last colon). Obviously no longer the whole filename.
You will need to escape any reserved characters in the filename before forming a URI.
You could do this on the command line, with for example:
ls | sed -e 's/:/%3A/g'
to transform the colons in the filename.
Or you could rename any files in the directory that use any of ";?:#&=+,$"
not exactly the same case, but we got:
ERROR 2999: Unexpected internal error. java.net.URISyntaxException cannot be cast to java.lang.Error
java.lang.ClassCastException: java.net.URISyntaxException cannot be cast to java.lang.Error
for everything we tried to load, and the problem was that the PIG_CONF_DIR env variable was pointing to a folder that did not exist. We've reset it in the .bash_profile to a folder with valid core-site.xml and mapred-site.xml and everything's good now.
export PIG_CONF_DIR=/my_good_folder