0

some samples of data are here

f = "optimal after sales service. Our customer friendly support system is truly one of a kind giving A Avon Watches a pride of place in the world of Indian watches.\\t0210PBH2YCA\\t1002004\\t499\\t\\t2015-02-10 16:43:27 IST\\t\\ty\\t1\\t\\t\\t11\\t\\t\\t\\tB00TFCNTGG\\t\\t\\t\\t\\t\\tB00TFCNTGG\\t\\t\\t\\tAMAZON_IN\\t\\tMigrated Template\\tActive\\t499.0\\nA Avon Sports Digital Black Dial Men\\\'s watch - 1002008\\tMulti functional Design Watch For Children\\\'s ; Tough Watch Case ; Stainless Steel Back ;Power Battery ; Tab For Date,Month & Multiple Light Effect ; Day & Time Display Together ; Stop Watch ; Calendar ; 12-24 Hour Time Display Option. A Avon Watches are Well known for amazing style and powerful features. The inbuilt features specify their usability. The elegantly designed A Avon Watches are apt to complement formal wear. A Avon Watches built with fine skills is backed by optimal after sales service. Our customer friendly support system is truly one of a kind giving A Avon Watches a pride of place in the world of Indian watches.\\t0216PZ3I06Y\\t1002008\\t499\\t\\t2015-02-16 15:45:58 IST\\t\\ty\\t5\\t\\t\\t11\\t\\t\\t\\tB00TOCAJ4C\\t\\t\\t\\t\\t\\t52E478CC519D7B2D\\t\\t\\t\\tAMAZON_IN\\t\\tMigrated Template\\tActive\\t499.0\\nA Avon Sports Digital Black Dial Women\\\'s Watch - 1002013\\tWatch Design For Children, Boys & Girls. A Avon Watches are Well known for amazing style and powerful features. The inbuilt features specify their usability. The elegantly designed A Avon Watches are apt to complement formal wear. A Avon Watches built with fine skills is backed by optimal after sales service. Our customer friendly support system is truly one of a kind giving A Avon Watches a pride of place in the world of Indian watches.\\t0216PZCK1E4\\t1002013\\t599\\t\\t2015-02-16 18:17:39 IST\\t\\ty\\t5\\t\\t\\t11\\t\\t\\t\\tB00TOGJ00M\\t\\t\\t\\t\\t\\t52E49B861FA1FF25\\t\\t\\t\\tAMAZON_IN\\t\ " z=f.split("\\\t") for i in z: print(i) print(len(z)) 

but it is not splitting it is printing same file as it is. I checked the length of z as well it is showing 1.

How to do that?

4
  • The code you posted throws an exception, it does not show a length of 1. Commented Oct 29, 2018 at 7:36
  • .readlines() returns a list of lines, calling .split on that will raise an Exception. Commented Oct 29, 2018 at 12:41
  • hi @L3viathan i have made some changes instead of file i decleared as string in that also it is not splitting the strings.? Commented Oct 29, 2018 at 12:48
  • Remove one of your backslashes: \\\t -> \\t. Otherwise you split on a backslash followed by a tab. Commented Oct 29, 2018 at 12:57

1 Answer 1

1

Your text does not contain any tabs '\t'so why would a split happen? There are a lot of backslashes \\ followed by a simple t, yet you try to split on backslashes followed by a tab. You can try:

f.split('\\t') 

and see the difference.

Sign up to request clarification or add additional context in comments.

1 Comment

it is not working on backslashes also. i tried that too.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.