Open a csv file

gtamir

New Member
Joined
Mar 12, 2021
Messages
5
Office Version
  1. 365
Hi, I exported a WhatsApp conversation to TXT file.
The problem is that in the text field if there is a LF character the next row goes to the Date field. So in Date field I have text from previous line.
How can I open this file properly in Excel?

WhatsApp Chat .txt
A
127/02/2017, 22:59 - Messages and calls are end-to-end encrypted. No one outside of this chat, not even WhatsApp, can read or listen to them. Tap to learn more.
227/02/2017, 22:58 - ‎‫שמעון שטרן‬‎ created group "‎‫הפרלמנט מטייל‬‎"
327/02/2017, 22:59 - ‎‫שמעון שטרן‬‎ added you
427/02/2017, 23:13 - שמעון שטרן: שלום חברים,במעמד 7 חברים הוחלט לפתוח קבוצה נוספת שתאפשר למטיילים לשתף את חברי הקבוצה בחוויותיהם ולקבל את תגובותיהם האוהדות, בד''כ.
5כתוצאה מכך, יהיה האתר הרגיל פחות עמוס ויהיה קל יותר להעביר דרכו הודעות ולתכנן אירועים.
6ז'ק, אתה יכול לחנוך את האתר החדש בכמה מהתמונות היפות שאתה מצלם בטיול.
7בברכת, למטיילים הידד
828/02/2017, 08:35 - +972 54-562-9487: רעיון מצויין.
9קדימה ז'ק, תחנות את הבית החדש.
1028/02/2017, 09:19 - ג'ורי: מברך על הרעיון
1128/02/2017, 09:20 - Giora Tamir: זה בתנאי שיהיו הרבה נסיעות.
1212/03/2017, 13:04 - אריה ויסמן: ?
1317/03/2017, 15:05 - שמעון שטרן: איזה קרנבל. ועוד למטרות טובות... יאיר, לא היה מרוץ 60 מ' עבורך ?
14גיורא, כמה עולה לילה עם ארוחת בוקר בצימר שצילמת ?
1517/03/2017, 17:10 - יאיר גרייבסקי: שמעון אם התכוונת אלי הצימר בעמוקה 630שח ללילה בלי ארוחת בוקר
WhatsApp Chat
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I don't know of anyway of importing merging the lines without some manipulation.
VBA & Power Query would allow you to manipulate it.
If its not too many lines you could open it in Word and get rid of the LF's you don't want.

If you want a quick and dirty this should work.
Just
  • select the Input cells in column A & hit delete
  • Copy in the new input data - just into column A under the heading
  • Make sure the formulas in B & C are copied to the bottom (same length as input data)
  • Filter on "Date Line" = Y
  • Paste special values column C to a new sheet.

20210314 WebChat Conversation conversion.xlsx
ABC
1INPUTOUTPUT
2
3OriginalDate Line YNCombined
427/02/2017, 22:59 - Messages and calls are end-to-end encrypted. No one outside of this chat, not even WhatsApp, can read or listen to them. Tap to learn more.Y27/02/2017, 22:59 - Messages and calls are end-to-end encrypted. No one outside of this chat, not even WhatsApp, can read or listen to them. Tap to learn more.
527/02/2017, 22:58 - ‎‫שמעון שטרן‬‎ created group "‎‫הפרלמנט מטייל‬‎"Y27/02/2017, 22:58 - ‎‫שמעון שטרן‬‎ created group "‎‫הפרלמנט מטייל‬‎"
627/02/2017, 22:59 - ‎‫שמעון שטרן‬‎ added youY27/02/2017, 22:59 - ‎‫שמעון שטרן‬‎ added you
727/02/2017, 23:13 - שמעון שטרן: שלום חברים,במעמד 7 חברים הוחלט לפתוח קבוצה נוספת שתאפשר למטיילים לשתף את חברי הקבוצה בחוויותיהם ולקבל את תגובותיהם האוהדות, בד''כ.Y27/02/2017, 23:13 - שמעון שטרן: שלום חברים,במעמד 7 חברים הוחלט לפתוח קבוצה נוספת שתאפשר למטיילים לשתף את חברי הקבוצה בחוויותיהם ולקבל את תגובותיהם האוהדות, בד''כ. כתוצאה מכך, יהיה האתר הרגיל פחות עמוס ויהיה קל יותר להעביר דרכו הודעות ולתכנן אירועים. ז'ק, אתה יכול לחנוך את האתר החדש בכמה מהתמונות היפות שאתה מצלם בטיול. בברכת, למטיילים הידד
8כתוצאה מכך, יהיה האתר הרגיל פחות עמוס ויהיה קל יותר להעביר דרכו הודעות ולתכנן אירועים.Nכתוצאה מכך, יהיה האתר הרגיל פחות עמוס ויהיה קל יותר להעביר דרכו הודעות ולתכנן אירועים. ז'ק, אתה יכול לחנוך את האתר החדש בכמה מהתמונות היפות שאתה מצלם בטיול. בברכת, למטיילים הידד
9ז'ק, אתה יכול לחנוך את האתר החדש בכמה מהתמונות היפות שאתה מצלם בטיול.Nז'ק, אתה יכול לחנוך את האתר החדש בכמה מהתמונות היפות שאתה מצלם בטיול. בברכת, למטיילים הידד
10בברכת, למטיילים הידדNבברכת, למטיילים הידד
1128/02/2017, 08:35 - +972 54-562-9487: רעיון מצויין.Y28/02/2017, 08:35 - +972 54-562-9487: רעיון מצויין. קדימה ז'ק, תחנות את הבית החדש.
12קדימה ז'ק, תחנות את הבית החדש.Nקדימה ז'ק, תחנות את הבית החדש.
1328/02/2017, 09:19 - ג'ורי: מברך על הרעיוןY28/02/2017, 09:19 - ג'ורי: מברך על הרעיון
1428/02/2017, 09:20 - Giora Tamir: זה בתנאי שיהיו הרבה נסיעות.Y28/02/2017, 09:20 - Giora Tamir: זה בתנאי שיהיו הרבה נסיעות.
1512/03/2017, 13:04 - אריה ויסמן: ?Y12/03/2017, 13:04 - אריה ויסמן: ?
1617/03/2017, 15:05 - שמעון שטרן: איזה קרנבל. ועוד למטרות טובות... יאיר, לא היה מרוץ 60 מ' עבורך ?Y17/03/2017, 15:05 - שמעון שטרן: איזה קרנבל. ועוד למטרות טובות... יאיר, לא היה מרוץ 60 מ' עבורך ? גיורא, כמה עולה לילה עם ארוחת בוקר בצימר שצילמת ?
17גיורא, כמה עולה לילה עם ארוחת בוקר בצימר שצילמת ?Nגיורא, כמה עולה לילה עם ארוחת בוקר בצימר שצילמת ?
1817/03/2017, 17:10 - יאיר גרייבסקי: שמעון אם התכוונת אלי הצימר בעמוקה 630שח ללילה בלי ארוחת בוקרY17/03/2017, 17:10 - יאיר גרייבסקי: שמעון אם התכוונת אלי הצימר בעמוקה 630שח ללילה בלי ארוחת בוקר
19
Sheet1
Cell Formulas
RangeFormula
B4:B18B4=IF(OR(MID($A4,3,1)="/",MID($A4,2,1)="/"),"Y","N")
C4:C18C4=IF(B5="N",A4& CHAR(10) &C5,A4)
 
Upvote 0
Open as raw text file and parse the Chr(10) before writing to the sheet
 
Upvote 0
Thank you, I'll give it a try. But this is an ad hock solution that I will not be able to use in another case.
I don't know of anyway of importing merging the lines without some manipulation.
VBA & Power Query would allow you to manipulate it.
If its not too many lines you could open it in Word and get rid of the LF's you don't want.

If you want a quick and dirty this should work.
Just
  • select the Input cells in column A & hit delete
  • Copy in the new input data - just into column A under the heading
  • Make sure the formulas in B & C are copied to the bottom (same length as input data)
  • Filter on "Date Line" = Y
  • Paste special values column C to a new sheet.

20210314 WebChat Conversation conversion.xlsx
ABC
1INPUTOUTPUT
2
3OriginalDate Line YNCombined
427/02/2017, 22:59 - Messages and calls are end-to-end encrypted. No one outside of this chat, not even WhatsApp, can read or listen to them. Tap to learn more.Y27/02/2017, 22:59 - Messages and calls are end-to-end encrypted. No one outside of this chat, not even WhatsApp, can read or listen to them. Tap to learn more.
527/02/2017, 22:58 - ‎‫שמעון שטרן‬‎ created group "‎‫הפרלמנט מטייל‬‎"Y27/02/2017, 22:58 - ‎‫שמעון שטרן‬‎ created group "‎‫הפרלמנט מטייל‬‎"
627/02/2017, 22:59 - ‎‫שמעון שטרן‬‎ added youY27/02/2017, 22:59 - ‎‫שמעון שטרן‬‎ added you
727/02/2017, 23:13 - שמעון שטרן: שלום חברים,במעמד 7 חברים הוחלט לפתוח קבוצה נוספת שתאפשר למטיילים לשתף את חברי הקבוצה בחוויותיהם ולקבל את תגובותיהם האוהדות, בד''כ.Y27/02/2017, 23:13 - שמעון שטרן: שלום חברים,במעמד 7 חברים הוחלט לפתוח קבוצה נוספת שתאפשר למטיילים לשתף את חברי הקבוצה בחוויותיהם ולקבל את תגובותיהם האוהדות, בד''כ. כתוצאה מכך, יהיה האתר הרגיל פחות עמוס ויהיה קל יותר להעביר דרכו הודעות ולתכנן אירועים. ז'ק, אתה יכול לחנוך את האתר החדש בכמה מהתמונות היפות שאתה מצלם בטיול. בברכת, למטיילים הידד
8כתוצאה מכך, יהיה האתר הרגיל פחות עמוס ויהיה קל יותר להעביר דרכו הודעות ולתכנן אירועים.Nכתוצאה מכך, יהיה האתר הרגיל פחות עמוס ויהיה קל יותר להעביר דרכו הודעות ולתכנן אירועים. ז'ק, אתה יכול לחנוך את האתר החדש בכמה מהתמונות היפות שאתה מצלם בטיול. בברכת, למטיילים הידד
9ז'ק, אתה יכול לחנוך את האתר החדש בכמה מהתמונות היפות שאתה מצלם בטיול.Nז'ק, אתה יכול לחנוך את האתר החדש בכמה מהתמונות היפות שאתה מצלם בטיול. בברכת, למטיילים הידד
10בברכת, למטיילים הידדNבברכת, למטיילים הידד
1128/02/2017, 08:35 - +972 54-562-9487: רעיון מצויין.Y28/02/2017, 08:35 - +972 54-562-9487: רעיון מצויין. קדימה ז'ק, תחנות את הבית החדש.
12קדימה ז'ק, תחנות את הבית החדש.Nקדימה ז'ק, תחנות את הבית החדש.
1328/02/2017, 09:19 - ג'ורי: מברך על הרעיוןY28/02/2017, 09:19 - ג'ורי: מברך על הרעיון
1428/02/2017, 09:20 - Giora Tamir: זה בתנאי שיהיו הרבה נסיעות.Y28/02/2017, 09:20 - Giora Tamir: זה בתנאי שיהיו הרבה נסיעות.
1512/03/2017, 13:04 - אריה ויסמן: ?Y12/03/2017, 13:04 - אריה ויסמן: ?
1617/03/2017, 15:05 - שמעון שטרן: איזה קרנבל. ועוד למטרות טובות... יאיר, לא היה מרוץ 60 מ' עבורך ?Y17/03/2017, 15:05 - שמעון שטרן: איזה קרנבל. ועוד למטרות טובות... יאיר, לא היה מרוץ 60 מ' עבורך ? גיורא, כמה עולה לילה עם ארוחת בוקר בצימר שצילמת ?
17גיורא, כמה עולה לילה עם ארוחת בוקר בצימר שצילמת ?Nגיורא, כמה עולה לילה עם ארוחת בוקר בצימר שצילמת ?
1817/03/2017, 17:10 - יאיר גרייבסקי: שמעון אם התכוונת אלי הצימר בעמוקה 630שח ללילה בלי ארוחת בוקרY17/03/2017, 17:10 - יאיר גרייבסקי: שמעון אם התכוונת אלי הצימר בעמוקה 630שח ללילה בלי ארוחת בוקר
19
Sheet1
Cell Formulas
RangeFormula
B4:B18B4=IF(OR(MID($A4,3,1)="/",MID($A4,2,1)="/"),"Y","N")
C4:C18C4=IF(B5="N",A4& CHAR(10) &C5,A4)
I
 
Upvote 0
Open as raw text file and parse the Chr(10) before writing to the sheet
Thanks Diddi. Do you mean to open with notepad and replace LF?
If yes there is a problem because LF is also a separator between records. So I'll have one big record.
 
Upvote 0
Thank you, I'll give it a try. But this is an ad hock solution that I will not be able to use in another case.

I

I think you will find that this formula based version will work on any Whats Apps text export file. (I haven't tried it on a file with images)
If you make the area an Excel Table, and then put the filter function over the top of that to extract just the Date Lines, then you effectively have an almost fully automated solution.
The missing parts being deleting the previous data and copying in the new data.

It can of course be done using VBA if you want to go that route. It is likely that you can do it in Power Query too.
 
Upvote 0
VBA:
VBA Code:
Row=1
Open "MyTextFile" For input as #1
    Do Until EOF(1)
        Line Input #1, textline
        textline=replace(textline, Chr(10), "")
        Row=Row +1
        cells(row,1) = textline
    Loop
Close
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,249
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top