BryceStevenWilley / visioning_texts

A D3 project that locally visualizes your messages from Signal or Whatsapp
GNU General Public License v3.0
37 stars 6 forks source link

Whatsapp chat error #14

Closed TheCesarMillan closed 4 years ago

TheCesarMillan commented 4 years ago

Hi, when I upload my WhatsApp chat it shows me this error FE7652E4-D79A-462B-852F-23B455CF38A2

BryceStevenWilley commented 4 years ago

Strange, I thought I had just fixed those issues in #2. Can you give me a bit of information:

htkcodes commented 4 years ago

Hey bryce.

Solved the issue for iphone whatsapp exports.

let full_data = lines.map(function(l) {

       let dash_idx = l.indexOf(']');
       let time_str = l.slice(0, dash_idx);
       let rest_str = l.slice(dash_idx + 1);
       let colon_idx = rest_str.indexOf(':');
       let name_str = rest_str.slice(0, colon_idx);
       let msg_str = rest_str.slice(colon_idx + 1);
       let dateparts=time_str.split('/');

 let day=dateparts[0].split('[')[1];
 let month=dateparts[1];
 let yr="20"
 let year=dateparts[2].split(",")[0];

 let fullyear=yr.concat(year);
let hour=dateparts[2].split(",")[1].split(":")[0];
let minute=dateparts[2].split(",")[1].split(":")[1];
let seconds=dateparts[2].split(",")[1].split(":")[2].split(" ")[0];
let meridian=dateparts[2].split(",")[1].split(":")[2].split(" ")[1];
let date =`${day}/${month}/${fullyear} ${hour}:${minute} ${meridian}`
       return {'name' : name_str.trim().split(' ')[0], 'BODY' : msg_str.trim(),
               'date' : new Date(date)};
   });
bumberboy commented 4 years ago

sample format from my side [29/11/18, 1:18:44 AM] Beetroot: hi

htkcodes commented 4 years ago

yea if you replace the function with mine. it should work, had the same issue

bumberboy commented 4 years ago

not with his latest code. he redid the regex searching part

BryceStevenWilley commented 4 years ago

Yeah, unfortunately @bumberboy's right, both htkcodes and I were working on this at the same time, give me a short bit to try to update the regex once again for AM/PM.

BryceStevenWilley commented 4 years ago

@bumerboy, htkcodes, try again, I think I've fixed most of these locale issues.

bumberboy commented 4 years ago

worked! real fun project. Thanks and cheers!

bumberboy commented 4 years ago
Screenshot 2020-01-21 at 2 55 05 PM

date parsing probably failed when the day or month is a single digit

BryceStevenWilley commented 4 years ago

Yep, I think I just fixed that in https://github.com/BryceStevenWilley/visioning_texts/commit/73734339bbcac6fb90653d064983c26c2f519a75 :sweat_smile: Thanks for being patient @bumberboy

bumberboy commented 4 years ago

your brace regex misses single digit days and months

[6/8/19, 9:54:47 PM] Beetroot: sweet

Try this ☺️:

/^\[([0-2][0-9]|3[0-1]|[0-9])([\.\/])((0[0-9])|(1[0-2])|[0-9])([\.\/])(\d{2}|\d{4}), (([0-9])?[0-9]):([0-9][0-9])(:[0-9][0-9])?( [aApP][mM])?\]/
BryceStevenWilley commented 4 years ago

https://github.com/BryceStevenWilley/visioning_texts/commit/39671950d32c585a4f14d13c7c340ef4abdc14f9 adds that new regex. Thanks a ton for the help!

TheCesarMillan commented 4 years ago

hi, an example line is like this: [05/01/20 14:28:41] Lilian: ‎Los mensajes y llamadas en este chat ahora están protegidos con cifrado de extremo a extremo.

I think the problem may be solved at parsing, the date and time are not separated by a coma, instead they are separate by a blank space, if you add the coma manually it solves the issue however I think it may still have an issue in "Word Use Difference" but it may be because it is a sample conversation with little info (was only about 20 messages long, that's why I edited it manually).

And the console shows me this: The input file has an ambigious date format. TODO(brycew): fix math.js:99 Example line: [05/01/20 14:28:41] Lilian Castillo: ‎Los mensajes y llamadas en este chat ahora están protegidos con cifrado de extremo a extremo. moment.js:293 Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info. Arguments: [0] _isAMomentObject: true, _isUTC: false, _useUTC: false, _l: undefined, _i: [05/01/20 14:28:41] Lilian Castillo: Hola Cesar, _f: undefined, _strict: undefined, _locale: [object Object] Error at Function.createFromInputFallback (file:///Users/cesar/Downloads/visioning_texts-master/lib/moment.js:320:98) at configFromString (file:///Users/cesar/Downloads/visioning_texts-master/lib/moment.js:2385:15) at configFromInput (file:///Users/cesar/Downloads/visioning_texts-master/lib/moment.js:2611:13) at prepareConfig (file:///Users/cesar/Downloads/visioning_texts-master/lib/moment.js:2594:13) at createFromConfig (file:///Users/cesar/Downloads/visioning_texts-master/lib/moment.js:2561:44) at createLocalOrUTC (file:///Users/cesar/Downloads/visioning_texts-master/lib/moment.js:2648:16) at createLocal (file:///Users/cesar/Downloads/visioning_texts-master/lib/moment.js:2652:16) at hooks (file:///Users/cesar/Downloads/visioning_texts-master/lib/moment.js:12:29) at file:///Users/cesar/Downloads/visioning_texts-master/src/math.js:121:26 at Array.map (<anonymous>) warn @ moment.js:293 math.js:181 Uncaught TypeError: Cannot read property 'texts' of undefined at math.js:181 at Array.reduce (<anonymous>) at xy_time_of_day (math.js:180) at graphs.js:492

htkcodes commented 4 years ago

hi, an example line is like this: [05/01/20 14:28:41] Lilian: ‎Los mensajes y llamadas en este chat ahora están protegidos con cifrado de extremo a extremo.

I think the problem may be solved at parsing, the date and time are not separated by a coma, instead they are separate by a blank space, if you add the coma manually it solves the issue however I think it may still have an issue in "Word Use Difference" but it may be because it is a sample conversation with little info (was only about 20 messages long, that's why I edited it manually).

And the console shows me this: The input file has an ambigious date format. TODO(brycew): fix math.js:99 Example line: [05/01/20 14:28:41] Lilian Castillo: ‎Los mensajes y llamadas en este chat ahora están protegidos con cifrado de extremo a extremo. moment.js:293 Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info. Arguments: [0] _isAMomentObject: true, _isUTC: false, _useUTC: false, _l: undefined, _i: [05/01/20 14:28:41] Lilian Castillo: Hola Cesar, _f: undefined, _strict: undefined, _locale: [object Object] Error at Function.createFromInputFallback (file:///Users/cesar/Downloads/visioning_texts-master/lib/moment.js:320:98) at configFromString (file:///Users/cesar/Downloads/visioning_texts-master/lib/moment.js:2385:15) at configFromInput (file:///Users/cesar/Downloads/visioning_texts-master/lib/moment.js:2611:13) at prepareConfig (file:///Users/cesar/Downloads/visioning_texts-master/lib/moment.js:2594:13) at createFromConfig (file:///Users/cesar/Downloads/visioning_texts-master/lib/moment.js:2561:44) at createLocalOrUTC (file:///Users/cesar/Downloads/visioning_texts-master/lib/moment.js:2648:16) at createLocal (file:///Users/cesar/Downloads/visioning_texts-master/lib/moment.js:2652:16) at hooks (file:///Users/cesar/Downloads/visioning_texts-master/lib/moment.js:12:29) at file:///Users/cesar/Downloads/visioning_texts-master/src/math.js:121:26 at Array.map (<anonymous>) warn @ moment.js:293 math.js:181 Uncaught TypeError: Cannot read property 'texts' of undefined at math.js:181 at Array.reduce (<anonymous>) at xy_time_of_day (math.js:180) at graphs.js:492

^\[([\d]{2}|[\d])\/([\d]{2}|[\d])\/([\d]{2})([\s,])(\s*)([\d]{2}|[\d]):(\d{2}):(\d{2})((\s\S+)|(]))\s([\s\w]+:|[\s\S]+:)([\s\S]+)

BryceStevenWilley commented 4 years ago

Thanks for the detailed feedback @TheCesarMillan

I think the problem may be solved at parsing, the date and time are not separated by a coma, instead they are separate by a blank space,

That does seem to be the case. Should be solved by https://github.com/BryceStevenWilley/visioning_texts/commit/fbe7cc4be868d9c063b0ea507ee84ce5c40c6515

it may still have an issue in "Word Use Difference" but it may be because it is a sample conversation with little info

Yep, there is some logic that gets rid of not-often used words, which for small conversations is all of them.

Feel free to try again, it should be fixed now!

TheCesarMillan commented 4 years ago

It works! Thanks :)