Maybe a little bit laborious, but it works (at least for the given examples):
imp = StringReplace[Import["Cycles_test.txt", "Text"], WhitespaceCharacter .. -> ""]
(*
"(),(20,21),(19,20),(19,20,21),(19,21,20),(19,21),(17,18),(17,18)(20,21),(17,18)(19,20),(17,18)(19,20,21),(17,18)(19,21,20),(17,18)(19,21),(16,17),(16,17)(20,21),(16,17)(19,20),(16,17)(19,20,21),(16,17)(19,21,20),(16,17)(19,21),(16,17,18),(16,17,18)(20,21),(16,17,18)(19,20),(16,17,18)(19,20,21),(16,17,18)(19,21,20)"
*)
then multiple string replacements:
cycleStrings = StringReplace[StringReplace[StringReplace[StringSplit[StringReplace[imp, "),(" -> ");("], ";"], {"(" -> "{",")" -> "}"}], "}{" -> "},{"], s__ :> "{" ~~ s ~~ "}"]
and finally:
Cycles[ToExpression[#]] & /@ cycleStrings
yields:
{Cycles[{}], Cycles[{{20, 21}}], Cycles[{{19, 20}}],
Cycles[{{19, 20, 21}}], Cycles[{{19, 21, 20}}], Cycles[{{19, 21}}],
Cycles[{{17, 18}}], Cycles[{{17, 18}, {20, 21}}],
Cycles[{{17, 18}, {19, 20}}], Cycles[{{17, 18}, {19, 20, 21}}],
Cycles[{{17, 18}, {19, 21, 20}}], Cycles[{{17, 18}, {19, 21}}],
Cycles[{{16, 17}}], Cycles[{{16, 17}, {20, 21}}],
Cycles[{{16, 17}, {19, 20}}], Cycles[{{16, 17}, {19, 20, 21}}],
Cycles[{{16, 17}, {19, 21, 20}}], Cycles[{{16, 17}, {19, 21}}],
Cycles[{{16, 17, 18}}], Cycles[{{16, 17, 18}, {20, 21}}],
Cycles[{{16, 17, 18}, {19, 20}}], Cycles[{{16, 17, 18}, {19, 20, 21}}],
Cycles[{{16, 17, 18}, {19, 21, 20}}]}
This could be converted into permutations by PermutationList
:
{{}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 21, 20}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 20, 19}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 20, 21, 19}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 21, 19, 20}, {1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 21, 20, 19}, {1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 17}, {1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 17, 19, 21, 20}, {1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 17, 20, 19}, {1, 2,
3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 17, 20, 21,
19}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 17,
21, 19, 20}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 18, 17, 21, 20, 19}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 17, 16}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 17, 16, 18, 19, 21, 20}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 17, 16, 18, 20, 19}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 17, 16, 18, 20, 21, 19}, {1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15, 17, 16, 18, 21, 19, 20}, {1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 16, 18, 21, 20, 19}, {1,
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 16}, {1, 2,
3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 16, 19, 21,
20}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 16,
20, 19}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17,
18, 16, 20, 21, 19}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 17, 18, 16, 21, 19, 20}}
Flatten[list]
prior to string operations. $\endgroup$t = Import[file, "String"]
, then you should be able to doStringReplace[t, "\n" -> ""]
. $\endgroup$