You are not logged in.

#1 2023-03-12 10:20:03

VoDo
Member
From: Europe
Registered: 2020-06-04
Posts: 122

[SOLVED]Python add lines between lines

Hi I know nothing about Python smile

How can I learn to do this automatically? What functions does that?

My input is this

Text-test_20230120_text-001.zip,output
Text-test_20230120_text-002.zip,output
Text-test_20230120_text-003.zip,output
Text-test_20230120_text-006.zip,output
Text-test_20230120_text-009.zip,output
Text-test_20230120_text-013.zip,output
Text-test_20230120_text-015.zip,output

The script should check for "continuity" 001-015 if 004 is missing add that line between 003 and 006 with .zip,input if 005 is missing do the same

I want to add lines between so output would be

Text-test_20230120_text-000.zip,input
Text-test_20230120_text-001.zip,output
Text-test_20230120_text-002.zip,output
Text-test_20230120_text-003.zip,output
Text-test_20230120_text-004.zip,input
Text-test_20230120_text-005.zip,input
Text-test_20230120_text-006.zip,output
Text-test_20230120_text-007.zip,input
Text-test_20230120_text-008.zip,input
Text-test_20230120_text-009.zip,output
Text-test_20230120_text-010.zip,input
Text-test_20230120_text-011.zip,input
Text-test_20230120_text-012.zip,input
Text-test_20230120_text-013.zip,output
Text-test_20230120_text-014.zip,input
Text-test_20230120_text-015.zip,output

Or is there any easy way how to do it?

Last edited by VoDo (2023-03-12 18:39:19)


Archi3

Offline

#2 2023-03-12 10:31:21

bulletmark
Member
From: Brisbane, Australia
Registered: 2013-10-22
Posts: 649

Re: [SOLVED]Python add lines between lines

I/we may possibly guess what you really want but you should state your requirements more clearly.

Last edited by bulletmark (2023-03-12 10:42:57)

Offline

#3 2023-03-12 10:44:50

VoDo
Member
From: Europe
Registered: 2020-06-04
Posts: 122

Re: [SOLVED]Python add lines between lines

bulletmark wrote:

I/we may possibly guess what you really want but you should state your requirements more clearly.

You are right that is the reason why I am not able to figured it out since I am not even able to write the problem correctly...

Is it now clearer?


Archi3

Offline

#4 2023-03-12 17:04:34

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,739

Re: [SOLVED]Python add lines between lines

I have to ask, is this a homework assignment?   If so, we can help you but the dialog will be to guide you to the answer.

You say you do not know Python.  Do you code in other languages?


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#5 2023-03-12 17:31:45

schard
Member
From: Hannover
Registered: 2016-05-06
Posts: 1,932
Website

Re: [SOLVED]Python add lines between lines

And while this question might be totally valid here, you'd probably get better answers on specialized sites, such as stackoverflow.

Last edited by schard (2023-03-12 17:32:31)

Offline

#6 2023-03-12 17:32:34

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,441
Website

Re: [SOLVED]Python add lines between lines

And why do you think python would be a good solution to this problem?

I'd use a printf/seq, join, sed pipeline.

Last edited by Trilby (2023-03-12 17:33:00)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2023-03-12 18:39:01

VoDo
Member
From: Europe
Registered: 2020-06-04
Posts: 122

Re: [SOLVED]Python add lines between lines

Trilby wrote:

And why do you think python would be a good solution to this problem?

I'd use a printf/seq, join, sed pipeline.

Thanks I will look at this


Archi3

Offline

Board footer

Powered by FluxBB