I’m trying to read a dataset using pd.read_csv() am getting an error. Excel can open it just fine.
reviews = pd.read_csv('br.csv')
gives the error ParserError: Error tokenizing data. C error: EOF inside string starting at line 312074
reviews = pd.read_csv('br.csv', engine='python', encoding='utf-8')
returns ParserError: unexpected end of data
What can I do to fix this?
Edit:
This is the dataset — https://www.kaggle.com/gnanesh/goodreads-book-reviews
asked Aug 30, 2018 at 21:34
RyanRyan
5051 gold badge5 silver badges14 bronze badges
3
For me adding this fixed it:
error_bad_lines=False
It just skips the last line.
So instead of
reviews = pd.read_csv('br.csv', engine='python', encoding='utf-8')
reviews = pd.read_csv('br.csv', engine='python', encoding='utf-8', error_bad_lines=False)
answered Oct 23, 2018 at 9:50
Elise MolElise Mol
3263 silver badges4 bronze badges
1
In my case, I don’t want to skip lines, since my task is required to count the number of data records in the csv file.
The solution that works for me is using the Quote_None from csv library.
I try this from reading on some websites that I did not remember, but it works.
To describe my case, previouly I have the error: EOF ….
Then I tried using the parameter engine=’python’. But that introduce another bug for next step of using the dataframe.
Then I try quoting=csv.Quote_None, and it’s ok now.
I hope this helps
import csv
read_file = read_csv(full_path, delimiter='~', encoding='utf-16 BE', header=0, quoting=csv.QUOTE_NONE)
answered Aug 15, 2019 at 9:01
0
When doing a reload in QlikView Developer/Desktop or utilizing QlikView Distribution Service / Publisher the following symptoms is experienced:
- The error message QVX_UNEXPECTED_END_OF_DATA appears in the Document Script log.
- Typically this happens intermittently e.g. the same script will reload just fine while at some occasions it will fail with the mentioned error message.
- The error message could appear in any script line.
- The error message appears when you have a open ODBC/OLEDB connection
Environment:
QlikView all versions
This error message appear when:
- Usage of CPU and/or RAM have reached their maximum on the Windows machine were the reload was performed
- The database server is heavily loaded and can’t provide the requested information
Resolution:
Turn on Windows performance monitor during a period of time and compare the results with reload(s) that fail. You should see a clear trend that tasks are failing when the Windows Server are running out of resources. If you run into these issues because of lack of RAM a quick fix would be to restart the Qlikview server service at a scheduled basis as that would free up resources. Also rescheduling the reload tasks based on the statistics from the Windows Performance Monitor logs would help as most probably there are timeslots during a 24 hour period were there are more resources available.
Another approach would be to consider to split up the QlikView services on two different machines.
If none of the above is feasible, upgrade the Windows Servers RAM and/or CPU.
When working with JSON data, it is common to encounter errors during parsing. One such error is the Unexpected end of JSON input at line 1 column 1 of the JSON data
. In this guide, we will explore the cause of this error and provide a step-by-step solution to fix it.
Table of Contents
- Understanding the Error
- Step-by-Step Solution
- FAQs
- Related Links
Understanding the Error
The error message Unexpected end of JSON input at line 1 column 1 of the JSON data
occurs when you attempt to parse an empty or invalid JSON string using the JSON.parse()
method. This error is usually due to:
- An empty JSON string being passed to the
JSON.parse()
method. - Incorrectly formatted JSON data, such as missing brackets, quotes, or commas.
Before diving into the solution, let’s understand the basics of the JSON.parse()
method.
JSON.parse()
The JSON.parse() method is a built-in JavaScript function used to convert a JSON string into a JavaScript object. It takes a JSON string as its argument and returns a JavaScript object based on the structure of the JSON data.
const jsonString = '{"name": "John", "age": 30}';
const jsonObj = JSON.parse(jsonString);
console.log(jsonObj); // { name: 'John', age: 30 }
Step-by-Step Solution
To fix the Unexpected end of JSON input at line 1 column 1 of the JSON data
error, follow these steps:
Verify the JSON data: Ensure that the JSON string being parsed is not empty and is properly formatted. You can use an online JSON validator, such as JSONLint, to check the validity of your JSON data.
Check for empty JSON strings: Add a conditional statement to check for empty JSON strings before calling the JSON.parse()
method. This will prevent the error from occurring when parsing an empty string.
const jsonString = '';
if (jsonString) {
const jsonObj = JSON.parse(jsonString);
console.log(jsonObj);
} else {
console.warn('Empty JSON string. Skipping JSON.parse().');
}
- Handle parsing errors: Wrap the
JSON.parse()
method in atry-catch
block to handle any errors that may occur during parsing. This is useful when dealing with dynamic JSON data, as it allows you to catch and handle errors gracefully.
const jsonString = '{"name": "John", "age": 30';
try {
const jsonObj = JSON.parse(jsonString);
console.log(jsonObj);
} catch (error) {
console.error('Error parsing JSON:', error.message);
}
By following these steps, you should be able to resolve the Unexpected end of JSON input at line 1 column 1 of the JSON data
error and handle any potential issues that may arise during JSON parsing.
FAQs
1. What is JSON?
JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to read and write and easy for machines to parse and generate. JSON is a text format that is completely language-independent but uses conventions that are familiar to programmers of the C family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. Learn more about JSON on the official JSON website.
2. How do I stringify a JavaScript object to JSON?
To convert a JavaScript object into a JSON string, you can use the JSON.stringify()
method. This method takes a JavaScript object as its argument and returns a JSON string representation of the object.
const jsonObj = { name: 'John', age: 30 };
const jsonString = JSON.stringify(jsonObj);
console.log(jsonString); // '{"name": "John", "age": 30}'
3. Can I use JSON.parse() with JSON data from an external API?
Yes, you can use JSON.parse()
to parse JSON data received from an external API. When you receive JSON data from an API, it is usually in the form of a JSON string. You can use JSON.parse()
to convert this JSON string into a JavaScript object that you can work with. However, ensure that you handle parsing errors using a try-catch
block, as demonstrated earlier in this guide.
4. Can JSON data include functions or methods?
No, JSON data cannot include functions or methods. JSON is a data-interchange format and does not support executable code, such as functions or methods. JSON data can only include simple data types, such as strings, numbers, booleans, objects (key-value pairs), and arrays.
No, JSON data does not support comments. JSON is a data-interchange format and is designed to be as simple as possible. Including comments in JSON data would make it more complex and harder to parse, which goes against the design goal of JSON.
- MDN Web Docs — JSON.parse()
- JSONLint — The JSON Validator
- MDN Web Docs — JSON.stringify()
- Official JSON Website
A free file archiver for extremely high compression
-
Summary
-
Files
-
Reviews
-
Support
-
Wiki
-
Tickets ▾
- Support Requests
- Patches
- Bugs
- Feature Requests
-
News
-
Discussion
Menu
▾
▴
Unexpected end of data error?
Created:
2020-12-23
Updated:
2020-12-28
-
So, I have a 37 GBs 7z file, that I can’t open, when testing it, it gives «unexpected end of data», any help would be wonderful, since this is all my data, thanks.
Also, this could be useful:
Archive size: 37,278,705,537 bytes.
some of the first bytes of the archive: https://hastebin.com/rupoqiwano.apache
some of the last bytes of the archive: https://hastebin.com/patigedocu.apache
-
Also, password protected archive.
-
First bytes:
37 7A BC AF 27 1C 00 04 46 0C A6 D2 50 90 3E CC 08 00 00 00 47 00 00 00 00 00 00 00 23 56 C5 BC 32 06 E9 39 52 A0 98 F5 A9 71 30 E6 5A 59 01 8E AD 55 A6 4B 42 53 E1 EF 95 5B 93 63 A0 1C AE 13 91 DB D7 58 30 86 66 B9 3D C2 0E D8 D5 3F 00 76 93 97 1A 86 A7 88 1D D1 ED 44 AF FE F2 87 15 91 91 5C 16 2E 77 57 E8 B5 A6 B3 86 77 30 9D A6 72 17 16 C9 95 9D D4 CE B5 D6 35 33 48 9F 0B DF C6 8C C8 A1 80 FB 42 E8 FF C8 27 D5 94 41 6B D5 EA 63 D1 34 40 1C BE 36 9F 3E 40 E7 46 6C BB 5D BD 1C A5 C8 A8 BD 40 C4 4ALast bytes:
51 CA 88 D1 47 01 9D C9 4D E7 61 AD 83 18 64 D5 40 BD 4F 9B C0 05 55 09 8D E2 24 98 BE 15 E8 03 71 76 B1 9F 8F DF E5 09 40 F8 28 FE 6C EE CC 06 FC F5 AE 03 44 62 DB 70 4D F1 73 99 DA F4 E4 18 A2 9E 58 AC 03 90 7D 47 85 8D 90 4E 54 EE 7F 70 DB BC 05 6E E5 BA 0A 96 6E 4A 0C 17 06 F8 F0 FE 1E CC 08 01 09 DF 60 91 00 07 0B 01 00 02 24 06 F1 07 01 12 53 0F 6C 40 04 6E 48 51 85 64 BA 58 C4 32 83 21 BE 1D 23 03 01 01 05 5D 00 00 10 00 01 00 0C DF 56 91 E3 02 7B A1
-
A1
is not last byte as I suppose
Show all last bytes.
Write how you created that archive.
Did you use multivolume 001, 002 ?
-
this file was done with 74 other 7z files, but that 7z file, does it without any errors really…
-
I done it like that because of hosting limitations…
-
and also, here are some of the last bytes:
0C 17 06 F8 F0 FE 1E CC 08 01 09 DF 60 91 00 07 0B 01 00 02 24 06 F1 07 01 12 53 0F 6C 40 04 6E 48 51 85 64 BA 58 C4 32 83 21 BE 1D 23 03 01 01 05 5D 00 00 10 00 01 00 0C DF 56 91 E3 02 7B A1 0A 01 B6 D5 6A D4 00 00Last edit: Igor Pavlov 2020-12-24
-
The start and the end of archive are correct.
But total archive size is incorrect.8CC3E9050+47+20=8CC3E90B7 = 37786390711 — real size of original 7z archive.
8ADFBE781 = 37278705537 bytes — size of corrupted archive
37786390711 — 37278705537 = 507685174 — it’s size of missing data.
So you must insert 507685174 bytes in some place of archive.
split 7z archive into 3 parts:
In 7-Zip / Menu / File / Split
write:and a.7z.002 will be small size of 1 byte.
Then create another random file of size
507685175
and rename it to a.7z.002
Then combine all 3 parts back to 37786390711 archiveDo all steps in another folder. Don’t remove original archive.
Maybe you will need another attempts to recover.Read
https://www.7-zip.org/recover.html
to understand headers of 7z archive.Last edit: Igor Pavlov 2020-12-24
-
I’m gonna be honest, I didn’t understand correctly, Could you help me out remotely? if yes, can you contact me at discord? If yes, here: «!jadssDev#0710», I really got a bit confused, so yeah, if you could, thanks!
-
before creating this post, I went into that page, tried to restore the header and the end header, didn’t work, yet I still didn’t understand what you mean, gonna be honest, I tried to understand hex but I couldn’t still, so Idk…. Sorry for the disappointment xD
-
The header and end header are ok in your file.
You just need to insert 507685174 bytes at the middle.
1) split archive into 3 parts.
2) create another part 2 of size of (old_size+507685174).
3) combine 3 parts back to single archive.
-
more simple way:
1) split into 4 parts:2) copy the file
a.7z.003
toa.7z.002
3) opena.7z.001
-
I just don’t get it how to split….
-
7-Zip file manager
select archive file
call menu File/Split file
write in «Split to volumes, bytes» box:
-
OK I’ll be sure to do it, talk to you tomorrow…
-
Also If You don’t bother, could I know how this happened? It’s really uncommon…
-
Describe all actions, programs, and hardware that you used to create and copy that archive.
-
the file was created on my HDD (damaged, the speed was really low) I done the file (didn’t test it) and then I splitted it into 74 adding the 7z file (36gbs) to 74 other 7z files, since I had a hosting limitation issue, then I just, downloaded them, and there was a problem, simple as that! waiting for ya answer.
-
I don’t understand about 74.
Describe each step: what exact names of archives and sizes did you have after each step?Last edit: Igor Pavlov 2020-12-26
-
Here:
1. Archived the file into 74 files, (named Desktop.001……..)
2. Uploaded all 74 files
3. Downloaded them back at my «new pc»
4. Bug. Simple as that.
-
1) What exact names of parts?
2) Look exact size of each part (each volume). Do all have same size?Last edit: Igor Pavlov 2020-12-26
-
They were the same size… no difference, only the last one was … 400mbs.. aprox.
They were Desktop.001 -> Desktop.074
-
Desktop.001
is unexpected name.
The expected name isDesktop.7z.001
, if it’s 7z archive that was split into volume parts.
Log in to post a comment.
zerozero 0 / 0 / 0 Регистрация: 08.06.2020 Сообщений: 1 |
||||||||
1 |
||||||||
08.06.2020, 01:36. Показов 6690. Ответов 2 Метки нет (Все метки)
Частично приходится работать с чужим старым кодом, где все работает на 100 из 100. Этот код используется полностью в аналогичной задаче, но в новом случае возникает ошибка SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data на 26 строке. Не понимаю — в чем загвоздка? помогите пожалуйста. код с ошибкой:
дополнительно ../models/filtr.php:
0 |
165 / 150 / 58 Регистрация: 15.06.2013 Сообщений: 1,093 |
|
08.06.2020, 10:06 |
2 |
На сколько я понимаю эта ошибка означает что у вас обрыв в jsone. Вероятно встречается какой-то символ, который жс не может распарсить. Что там за строка хоть?
1 |
Kerry_Jr 3105 / 2590 / 1219 Регистрация: 14.05.2014 Сообщений: 7,236 Записей в блоге: 1 |
||||
08.06.2020, 11:32 |
3 |
|||
Проверяйте, выполнение данных операций, приходит пустой результат, о чем JS вам и говорит.
1 |
IT_Exp Эксперт 87844 / 49110 / 22898 Регистрация: 17.06.2006 Сообщений: 92,604 |
08.06.2020, 11:32 |
Помогаю со студенческими работами здесь
Parse error: syntax error, unexpected $end in /var/www/timo/data/www/mysite.ru/engine/ajax/upload.php on line 1340 Ошибка! Uncaught SyntaxError: Unexpected token < in JSON at position 0 Не работает JSON.parse, ошибка Unexpected token o var obj=JSON.parse (<?=$Arrbankomat?>); Парсинг JSON в JSON Linked Data с использованием Hydra Java Конвертер (сериализатор) JSON -> JSON Linked Data Искать еще темы с ответами Или воспользуйтесь поиском по форуму: 3 |